Lesson 25. Using Triggers

In this lesson, you learn what triggers are, why they are used, and how. You also look at the syntax for creating and using them.

Understanding Triggers

T-SQL statements are executed when needed, as are stored procedures. But what if you want a statement (or statements) to be executed automatically when events occur? Here are some examples:

Image Every time a customer is added to a database table, check that the phone number is formatted correctly and that the state abbreviation is in uppercase.

Image Every time a product is ordered, ...

Get Sams Teach Yourself Microsoft® SQL Server T-SQL in 10 Minutes, Second Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.