From the course: SQL Server Database Triggers

Unlock the full course today

Join today to access over 22,700 courses taught by industry experts or purchase this course individually.

Disable nested triggers

Disable nested triggers - SQL Server Tutorial

From the course: SQL Server Database Triggers

Start my 1-month free trial

Disable nested triggers

- By default SQL server will allow you to have triggers that execute commands that in turn fire additional triggers, and that'll allow you to create a chain of up to 32 separate events. This is a server level property called Nested Triggers. To see this in action let's create two tables. I've creatively decided to name these first table, and second table. The first table is just going to have a row ID, and a value that we can place in there. And the second table will have a row ID, and a date that we could put in. So let's go ahead and create both of those tables, and then I'm going to create a couple of triggers. Now the first trigger is going to be on the first table. It'll be an after insert table. So anytime we answered a new row into the table, we're going to insert a row into the second table. And the value that we're going to put in is just the current date and time. So essentially we're writing a timestamp into…

Contents