如何在T-SQL 2005中删除之前触发触发器?FOR实际上在事件发生后触发,它们似乎在TRIGGER函数中没有BEFORE参数.INSTEAD OF不是我想要的.我需要在删除记录之前触发.有任何想法吗?
您可以使用INSTEAD OF选项,只需在末尾显式删除行.例如:
CREATE TRIGGER dbo.My_Table_Delete_Instead_Of_Trigger ON dbo.My_Table INSTEAD OF DELETE AS BEGIN -- Do some stuff here DELETE T FROM DELETED D INNER JOIN dbo.My_Table T ON T.PK_1 = D.PK_1 AND T.PK_2 = D.PK_2 END
这假定主键由PK_1和PK_2列组成.
你不能.但是您可以在AFTER DELETE触发器中执行回滚.