开发者

MS SQL Server 2008 changing inserted row value in trigger

开发者 https://www.devze.com 2023-03-01 17:58 出处:网络
In Orac开发者_如何学Cle i can change the row value by :new.column_name = new_value in insert/update trigger.

In Orac开发者_如何学Cle i can change the row value by :new.column_name = new_value in insert/update trigger. How can I do the same in MS SQL 2008 Trigger?


Unlike Oracle, affected records are passed in sets to SQL Server triggers, referenced to as INSERTED and DELETED.

You will have to update the target table:

UPDATE   m
SET      column_name = @new_value
FROM     INSERTED i
JOIN     mytable m
ON       m.id = i.id

or, better, create an INSTEAD OF trigger.

0

精彩评论

暂无评论...
验证码 换一张
取 消