Can we update the primary key of a table using a trigger in sql server 2005.
I want to update the primary key of another table if it is changed in the first table,
so i want to use the old value in the table to update its new value.Hence, kindly provide me that solution.
asked Feb 04, 2010 at 01:19 AM in Default
Yes you can, assuming the key in the target table is not an IDENTITY. IDENTITY columns can't be updated.
You don't need a trigger. I think the easiest way would be to create a foreign key constraint on the key that needs to be updated and use the ON UPDATE CASCADE option:
answered Feb 04, 2010 at 04:27 AM