From the course: Hands-On Advanced SQL Server: Strategies and Techniques

Unlock this course with a free trial

Join today to access over 25,500 courses taught by industry experts.

DDL triggers

DDL triggers

- [Instructor] So we just took a look at a few different types of Data Manipulation Language triggers, or DML for short. Now we're going to segue and take a look at a different type of triggers called Data Definition Language triggers, or DDL for short. Unlike the DML triggers, which respond to data changes, Data Definition Language triggers respond to schema changes. So any structural changes that someone attempts to do in your database, you have a way of controlling that through Data Definition Language triggers. All right, so let's take a look at the code in front of us here. This is some code that I set up, which is creating our Data Definition Language trigger. Now, this trigger is going to listen for any CREATE_TABLE command in the current database, and if someone tries to run a CREATE_TABLE command, SQL Server will immediately cancel the action using this ROLLBACK TRANSACTION. So just to look at the individual parts, I'm simply naming my trigger here and applying it on a…

Contents