Using Trigger Resources

Triggers have access to resources and information that other T-SQL statements don't. They can roll back transactions, undoing an action. They can look at both the old and new versions of rows that are being modified by a statement. And they can determine which columns were modified. To see how all this works, we will write some simple examples to show how these resources are used.

Accessing the INSERTED and DELETED Tables

In the section where I described the program flow of an UPDATE statement, you saw that all the deletes and inserts are written to a log file. Those logged rows are available to a trigger as the INSERTED and DELETED tables. SQL Server 2000 automatically creates and manages these two tables. You can use the ...

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.