
[dbo].[MssWebSetAccountProfilePrimaryContact]
CREATE PROCEDURE [dbo].[MssWebSetAccountProfilePrimaryContact]
@orderId int,
@contactId int
AS
begin
set nocount on
;with MergeData as
(
select OrderId = @orderId
from Orders
inner join AccountProfileContacts on
Orders.AccountProfileFID = AccountProfileContacts.AccountProfileFID and
AccountProfileContacts.AccountProfileContactID = @contactId
where Orders.PriKey = @orderId
) merge AccountProfileOrderPrimaryContact with (tablock) using MergeData on
AccountProfileOrderPrimaryContact.OrderFID = MergeData.OrderId
when matched then update set AccountProfileContactFID = @contactId
when not matched then insert
(
AccountProfileContactFID,
OrderFID
)
values
(
@contactId,
@orderId
)
;
end
GO
GRANT EXECUTE ON [dbo].[MssWebSetAccountProfilePrimaryContact] TO [MssExec]
GO