From the course: SQL Server Database Triggers

Unlock the full course today

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

Firing INSTEAD OF triggers

Firing INSTEAD OF triggers - SQL Server Tutorial

From the course: SQL Server Database Triggers

Start my 1-month free trial

Firing INSTEAD OF triggers

- [Teacher] Within instead of trigger, you can intercept a T-SQL command and completely replace it with a different set of instructions. We can use this to create a trigger. That'll prevent any rows from being deleted from a table. Let's set up the structure by creating a new table called accounts payable in the Connecticut TRG database. This table will have two columns account id and account number. And then I'm going to insert three different rows of values into the table. I'll highlight lines one through 13 and execute them to set up the structure. And then we'll select everything from that table. So this is our starting point. We have a table with three different rows in it. Now I want to set up a trigger. That'll prevent any of these values from being deleted from the table. We do that starting on line number 18. Here, I'm going to create a trigger called dbo.AccountsDelete. We're going to attach it on the…

Contents