How to Use Nested Triggers in SQL Server 2012


show more Using nested triggers provides you with in-depth training on Business. Taught by Martin Guidry as part of the SQL Server: Triggers, Stored Procedures, and Functions show less
please wait ...

Using nested triggers

In our two previous examples we created one trigger that will block deletions from the categories table, instead marking records as inactive, and we created another trigger that when a category is marked as inactive, it marks all products as inactive also. This means that if I issue a DELETE statement, the first trigger fires, blocking my DELETE statement, and instead updating the record. That update, the update that was caused by the trigger, will in turn cause the second trigger to fire.

This situation where the actions of one trigger cause the next trigger to fire is called nested triggers. The ability to nest triggers is turned on by default, but you can turn it off if you want to. I have some code in your exercise files that will do this. It's an SP configure, the feature we would like to configure is nested triggers. It is turned on by default which would be a 1. So we'll use a 0 to turn it off and if you'd like to turn it back on, just use a 1.

Even when nested triggers ...

Using nested triggers
Video duration: 1m 38s 1h 52m Advanced

Viewers:

Using nested triggers provides you with in-depth training on Business. Taught by Martin Guidry as part of the SQL Server: Triggers, Stored Procedures, and Functions

Subjects:
Business Developer IT
Software:
SQL Server
Author:
please wait ...