MSSQL触发器如何指定几个字段发生改变后触发
MSSQL触发器如何指定几个字段发生改变后触发
create trigger TR_MasterTable_Update
on MasterTable
after update
as
if update (T1)--当T字段被更新时,才会触发此触发器
如果要监视两个以上字段怎么写?
if update (T2,T1)--语法错
[解决办法]
if ((select t1 from inserted)!=(select t1 from deleted)) and
((select t2 from inserted)!=(select t2 from deleted))
...
[解决办法]
if update (T2,T1)--语法错,改為:if update(T2) or update(T1)
[解决办法]
if update(T1) or update(T2)