sql server触发器中增删改判断

触发器生效逻辑

在Before或者After之后使用INSERT,DELETE,UPDATE

触发器内情况判断

  • 插入
    if exists(select 1 from inserted) and not exists(select 1 from deleted)
  • 删除
    ELSE if exists(select 1 from deleted) and not exists(select 1 from inserted)
  • 更新
    ELSE if exists(select 1 from deleted) and exists(select 1 from inserted)
原文地址:https://www.cnblogs.com/shenfeng/p/4624137.html