O'Reilly logo

Microsoft® SQL Server 2008 R2 Unleashed by Alex T. Silverstein, Chris Gallelli, Paul Bertucci, Ray Rankins

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Creating DDL Triggers

The basic syntax for creating a DDL trigger follows:

image

The best way to illustrate the use of the DDL trigger syntax and power of these triggers is to look at a few examples. The example shown in Listing 30.14 illustrates the creation of a DDL trigger that is scoped at the database level and prevents table-level changes.

Listing 30.14 A Database-Scoped DDL Trigger for Tables

image

This trigger is fired whenever the CREATE, ALTER, or DROP TABLE statements are executed. Consider, for example, the following statements that can be run ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required