开发者

sql server db trigger when certain field changes

开发者 https://www.devze.com 2022-12-16 03:13 出处:网络
is there anyway to put a condition in a SQL server trigger to say fire when field \"XYZ\" changes ? EDIT:

is there anyway to put a condition in a SQL server trigger to say fire when field "XYZ" changes ?

EDIT:

what is the correct SQL syntax to basically insert into a new field

开发者_开发问答
Field XZY has changes from Value A to value B


the trigger will always fire but you can break it's execution by using UPDATE() and COLUMNS_UPDATED methods inside the trigger


you can have a conditional section anywhere within your trigger statement using

IF UPDATE (column_name)
BEGIN
    IF (SELECT column_name FROM INSERTED) = 'B'
    BEGIN
        /* do something */
    END
END
0

精彩评论

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