[dbo].[InternationalBookingNumberAddresses]
SET QUOTED_IDENTIFIER OFF
GO
CREATE view [dbo].[InternationalBookingNumberAddresses]
(
InternationalBookingNumberFID,
PickupContact,
PickupAddress,
PickupCity,
PickupState,
PickupCountryCodeStandardFID,
PickupPostalCode,
ReturnContact,
ReturnAddress,
ReturnCity,
ReturnState,
ReturnCountryCodeStandardFID,
ReturnPostalCode
)
as
select
InternationalBookingNumberFID = InternationalBookingNumber.InternationalBookingNumberID,
PickupContact = PickupAddress.Contact,
PickupAddress = dbo.BuildAddressFromAddressParts
(
PickupAddress.Address1,
PickupAddress.Address2,
PickupAddress.Address3
),
PickupCity = PickupAddress.City,
PickupState = PickupAddress.State,
PickupCountryCodeStandardFID = PickupAddress.CountryCodeStandardFID,
PickupPostalCode = PickupAddress.PostalCode,
ReturnContact = ReturnAddress.Contact,
ReturnAddress = dbo.BuildAddressFromAddressParts
(
ReturnAddress.Address1,
ReturnAddress.Address2,
ReturnAddress.Address3
),
ReturnCity = ReturnAddress.City,
ReturnState = ReturnAddress.State,
ReturnCountryCodeStandardFID = ReturnAddress.CountryCodeStandardFID,
ReturnPostalCode = ReturnAddress.PostalCode
from InternationalBookingNumber
left outer join AddressType as PickupType on PickupType.TypeName = 'Pickup'
left outer join InternationalBookingNumberAddress as PickupAddress on
(
InternationalBookingNumber.InternationalBookingNumberID = PickupAddress.InternationalBookingNumberFID and
PickupType.AddressTypeID = PickupAddress.AddressTypeFID
)
left outer join AddressType as ReturnType on ReturnType.TypeName = 'Return'
left outer join InternationalBookingNumberAddress as ReturnAddress on
(
InternationalBookingNumber.InternationalBookingNumberID = ReturnAddress.InternationalBookingNumberFID and
ReturnType.AddressTypeID = ReturnAddress.AddressTypeFID
)
GO
GRANT SELECT ON [dbo].[InternationalBookingNumberAddresses] TO [MssExec]
GRANT INSERT ON [dbo].[InternationalBookingNumberAddresses] TO [MssExec]
GRANT DELETE ON [dbo].[InternationalBookingNumberAddresses] TO [MssExec]
GRANT UPDATE ON [dbo].[InternationalBookingNumberAddresses] TO [MssExec]
GO