Mansoor
Mansoor

Reputation: 285

SQL Server : triggers to fire

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

Last query will fire trigger1 and trigger2.

Whether trigger1 fires trigger2 again (if database default options are set)?

Upvotes: 0

Views: 141

Answers (2)

Kenneth Fisher
Kenneth Fisher

Reputation: 3812

If the option RECURSIVE_TRIGGERS is set to on and the configuration "nested triggers" is set to 1 then then yes firing trigger1 will cause both trigger1 and trigger2 to fire again and then again etc up to 32 levels deep for after triggers. Otherwise no they won't fire recursively.

Upvotes: 1

roryWoods
roryWoods

Reputation: 4868

It depends on the nested triggers setting on the server. See:

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

Upvotes: 1

Related Questions