create trigger trigger_all on table_a for insert,update,delete as if not exists(select * from deleted) and exists(select * from inserted)---插入 begin insert into table_middle (id,kind,time) select id1,'I',getDate() from inserted end else if exists(select * from deleted) and not exists(select * from inserted)---删除 begin insert into table_middle (id,kind,time) select id1,'D',getDate() from deleted end else if exists(select * from deleted) and exists(select * from inserted)---更新 begin insert into table_middle (id,kind,time) select id1,'U',getDate() from inserted end