请问如何在触发器中判断是触发的修改,还是删除。。
create trigger tgr_ba0
on ba2
after update, delete
as
--修改
if exists(select 1 from inserted) and exists(select 1 from deleted)
begin
insert into log(action) values('updated');
end
else if (exists (select 1 from inserted) and not exists (select 1 from deleted))
begin
insert into log(action) values('inserted');
end
else if (not exists (select 1 from inserted) and exists (select 1 from deleted))
begin
insert into log(action) values('deleted');
end
go
posted on 2016-01-11 18:42 struggle_beiJing 阅读(1650) 评论(0) 编辑 收藏 举报