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.

Rollback database modifications

Rollback database modifications - SQL Server Tutorial

From the course: SQL Server Database Triggers

Start my 1-month free trial

Rollback database modifications

- [Narrator] With DDL triggers, database developers can create a system that'll prevent structural changes from being made to a table. Let's take a look by creating a new trigger called prevent table alterations. I'm going to scope this to the current database, which will be the KineticoTRG database. So I'll say on database on line number five. Then, I want to target just alter table commands that are sent to this database. So on line six, we say for alter table. Then after the as command, we have the different commands that I want the trigger to execute. The first one is just a simple print statement. We'll print the line, a trigger is canceling all alter table statements. Then we'll issue the rollback command to roll back the transaction and undo any changes that the original alter table statement was trying to do. Let's go ahead and create this trigger on the KineticoTRG database and now we can test it out. First…

Contents