Microsoft SQL Server 2012 Bible
by Adam Jorgensen, Jorge Segarra, Patrick LeBlanc, Jose Chinchilla, Aaron Nelson
Chapter 36
Creating Triggers
In This Chapter
Creating Instead of and After Triggers
Using the Transaction's Data Within the Trigger
Integrating Multiple Triggers
Creating DDL Database Triggers
Preventing Server or Database Changes
Reading Event Data with XML
Understanding Security Triggers
SQL Server triggers are special stored procedures attached to table events. They can't be executed directly, but fire only in response to an INSERT, UPDATE, or DELETE event on a table. Users can't bypass a trigger; and unless the trigger sends a message to the client, the end user is unaware of its actions.
Developing well-behaved triggers involves understanding transaction flow, locking, T-SQL, and stored procedures. Triggers have a few unique elements that require careful planning, but they provide execution of complex business rules and data validation.
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access