例如:把有異動的資料塞到其他table,就可以針對異動資料做其他處理。
方法:在table展開的觸發程序按右鍵選新增或是直接執行下面的sql(TABLENAME要修改)
SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TRIGGER dbo.triggerProg ON dbo.TABLENAME AFTER INSERT,DELETE,UPDATE AS BEGIN SET NOCOUNT ON; --insert event if (Select Count(*) From inserted) > 0 and (Select Count(*) From deleted) = 0 begin SELECT * FROM inserted --1 end --delete event if (Select Count(*) From inserted) = 0 and (Select Count(*) From deleted) > 0 begin SELECT * FROM deleted --2 end --update event if (Select Count(*) From inserted) > 0 and (Select Count(*) From deleted) > 0 begin SELECT * FROM inserted --3 end END GO上面1,2和3式子,可以修改成自己想要的sql,而且可以取到TABLENAME的欄位。