Summary

What you have seen in today's lesson is how to create and use one of the most misunderstood and powerful tools in a SQL database. A trigger enables you to specify a set of SQL statements that you want executed either instead of or after one of the three data modification actions is performed. Remember that a trigger is executed only once per triggering statement, no matter how many rows are being modified by the statement.

The SQL Server will use transactions and locks to ensure that a trigger will run by itself. Your trigger also has access to the INSERTED and DELETED tables, which give you the information about the data being modified, both before and after the modification.

Finally, because you cannot specify when the trigger should ...

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.