© Lisa Bohm 2020
L. BohmRefactoring Legacy T-SQL for Improved Performancehttps://doi.org/10.1007/978-1-4842-5581-0_5

5. Triggers

Lisa Bohm1 
(1)
Chardon, OH, USA
 

Triggers are objects that run when data changes (or in some cases, schema changes). They can run against tables or views and can be, well, triggered by inserts, updates, or deletes. There are some caveats on using them against a view (besides my personal opinion, which is: please don’t).

Each trigger has two tables that you can use to query data that has changed. There is an INSERTED table and a DELETED table. If you are firing a trigger on an INSERT, there will be records in the INSERTED table but none in the DELETED table. If you are firing a trigger on a DELETE, there will be records in ...

Get Refactoring Legacy T-SQL for Improved Performance: Modern Practices for SQL Server Applications 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.