Reputation: 25
I have tables master_product
and transactions
.
If I change productID
in the master_product
table, I want to update the ProductID
column in the transactions
table.
I want to use a trigger, but I don't know how to write it. Can you please help me write the trigger?
Thank you.
Upvotes: 0
Views: 287
Reputation: 71
It may be easier to change your foreign key constraint and add "ON UPDATE CASCADE" ?
SQL Server will manage everything.
alter table Categories drop constraint your_constraint_name
go
alter table Categories add constraint your_constraint_name
foreign key (productID) references master_product (productID) on update cascade on delete no action
Upvotes: 1