Wednesday, March 23, 2011

Updating multiple rows from trigger byy inserted table

Hi All
Many times we are facing that we need to change the value of Column1 of Table2 when Table1 updates.

This below is given solution by- Nipam Budhabhatti
So we need trigger.
We can either select value in some variable.
but it has problem that we cannt update all rows.
so this is the solution
by implementing it we are sure that all records in Table2 are updated after updating table1.

CREATE TRIGGER [TrgName] ON Table1
FOR UPDATE
AS
UPDATE Table2
SET
Column1 = INSERTED.Column2
FROM INSERTED
WHERE
Column3 = Column4


Nipam Budhabhatti

Nipam Budhabhatti

No comments:

Post a Comment