SQL Server:触发器触发

时间:2013-02-20 18:01:34

标签: sql-server triggers

CREATE table1;
CREATE table2;

CREATE trigger1 ON table1 AFTER DELETE AS DELETE FROM table1;
CREATE trigger2 ON table1 AFTER DELETE AS DELETE FROM table2;

DELETE FROM table1

上次查询将触发trigger1trigger2

trigger1是否再次触发trigger2(如果设置了数据库默认选项)?

2 个答案:

答案 0 :(得分:1)

这取决于服务器上的nested triggers设置。参见:

http://msdn.microsoft.com/en-us/library/ms190739.aspx

答案 1 :(得分:1)

如果选项RECURSIVE_TRIGGERS设置为on并且配置“嵌套触发器”设置为1然后是触发trigger1将导致trigger1和trigger2再次触发,然后再触发等等至32级深度后触发。否则他们不会递归发射。