RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX

Tip of the Day
Language: SQL
Expertise: Intermediate
Nov 29, 2005

Turning Recursive and Nested Triggers On and Off

To check whether nested triggers are turned on or off in SQL Server, issue the following command in Query Analyzer:

EXEC sp_configure 'nested triggers'
If the run_value is 0 then the nested triggers are off, if the value is 1 then they are on.

Therefore, to turn on nested triggers, type the following command:

EXEC sp_configure 'nested triggers', 1
To turn them off, type the following:

EXEC sp_configure 'nested triggers', 0
As you can see, the nested trigger setting works on a server level.

On the other hand, the recursive trigger setting works on a database level, so those commands require you to specify a database. To check the status of the recursive setting, issue this command:

EXEC sp_dboption '<name of db>', 'recursive triggers'
Use this command to turn them:

EXEC sp_dboption '<name of db>', 'recursive triggers', 'true'
Use this command to turn them off:

EXEC sp_dboption '<name of db>', 'recursive triggers', 'false'
Sachin Kainth
Close Icon
Thanks for your registration, follow us on our social networks to keep up-to-date