SQLSERVER触发器触发INSERT,UPDATE,DELETE三种状态
一个触发器内三种INSERT,UPDATE,DELETE状态
CREATE TRIGGER tr_T_A ON T_A for INSERT,UPDATE,DELETE
如IF exists (select * from inserted) and not exists (select * from deleted) 则为 INSERT
如IF exists(select * from inserted ) and exists (select * from deleted) 则为 UPDATE
如IF exists (select * from deleted) and not exists (select * from inserted)则为 DELETE
插入操作(Insert):Inserted表有数据,Deleted表无数据
删除操作(Delete):Inserted表无数据,Deleted表有数据
更新操作(Update):Inserted表有数据(新数据),Deleted表有数据(旧数据)