在Sql Server触发器中判断操作是Insert还是Update还是Delete
1个回答
展开全部
declare
@isIns bit -- 是否插入
, @isUpd bit -- 是否更新
, @isDel bit -- 是否删除
select
@isIns = (case when exists(select top 1 1 from inserted) and not exists(select top 1 1 from deleted) then 1 else 0 end)
, @isDel = (case when not exists(select top 1 1 from inserted) and exists(select top 1 1 from deleted) then 1 else 0 end)
, @isUpd = (case when exists(select top 1 1 from inserted) and exists(select top 1 1 from deleted) then 1 else 0 end)
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |