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