Chapter 14. Triggers

After completing this chapter, you will be able to

  • Create DML triggers

  • Create DDL triggers

Triggers provide a means to allow you to automatically execute code when an action occurs. Two types of triggers are available in Microsoft SQL Server 2008: DML and DDL. In this lesson, you will learn how to create DML triggers that execute when you add, modify, or remove rows in a table. You will also learn how to create DDL triggers that execute when DDL commands are executed or users log in to an instance.

DML Triggers

Although functions and stored procedures are stand-alone objects, you can’t directly execute a trigger. DML triggers are created against a table or a view, and are defined for a specific event—INSERT, UPDATE, or DELETE

Get Microsoft® SQL Server® 2008 Step by Step now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.