I am using this trigger:
create trigger UpdateCustomerOnWholeSellerIdChange
on Invoice after update
as
begin
set nocount on;
if update(WholeSellerId)
begin
update Customer
set Customer.WholeSellerId = d.WholeSellerId
from deleted d
where d.CustomerId = Customer.CustomerId
end
end
What I am trying to accomplish is: each CustomerId has his own WholeSellerId meaning each Customer has their own salesman. In the Invoice table, each Invoice has its own CustomerId and WholeSellerId.
So when I update the WholeSellerId in the Invoice table, I would like to update the WholeSellerId of the Customer table as well to the WholeSellerId of the Invoice table.
With my code above, even when I update my WholeSellerId in the Invoice table, it doesn't update the Customer's WholeSellerId.
Your help is appreciated.
UPDATEaffects more than one invoice for the same customer and updatesWholeSellerIdto different values?