[dbo].[MssWebGetOrderSakariCustomerContacts]
create procedure [dbo].[MssWebGetOrderSakariCustomerContacts]
@inOrderId int
as
begin
set nocount on
select
PhoneType = OrderPhoneType.TypeName,
CountryCode = isnull(CountryCodeStandard.PhoneCountryCode,DefaultCountryCode.PhoneCountryCode),
CountryCodeStandardId = isnull(CountryCodeStandard.CountryCodeStandardID, DefaultCountryCode.CountryCodeStandardID),
AreaCode = OrderPhoneNumber.AreaCode,
LocalNumber = OrderPhoneNumber.LocalNumber
from OrderPhoneNumber
cross join dbo.getDefaultCountry() as DefaultCountryCode
inner join OrderPhoneType on
OrderPhoneNumber.OrderPhoneTypeFID = OrderPhoneType.OrderPhoneTypeID and
OrderPhoneType.IsShipperPhoneType = 1
left outer join CountryCodeStandard on OrderPhoneNumber.CountryCodeStandardFID = CountryCodeStandard.CountryCodeStandardID
where OrderPhoneNumber.OrderFID = @inOrderId
end;
GO
GRANT EXECUTE ON [dbo].[MssWebGetOrderSakariCustomerContacts] TO [MssExec]
GO