Understanding Triggers

A trigger is a special class of stored procedure that is defined and designed to execute automatically when an UPDATE INSERT, or DELETE statement is issued against a table or view in the database. In addition, a trigger can query other tables and can include complex SQL statements. For example, you could control whether to allow an order to be added to the database based on the customer's current account status.

Some of the advantages of using triggers are

  • Because triggers are automatic, they are activated immediately after any modification to the table's data, such as a manual entry or an application action.

  • They can cascade any changes through related tables in the database.

  • They can be used to enforce restrictions that ...

Get Sams Teach Yourself Transact-SQL in 21 Days, Second Edition 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.