How Triggers Are Processed

From a 40,000-foot view, both triggers and stored procedures are processed similarly. When you take a closer look, you see some major differences. As I mentioned earlier, probably the largest difference is that triggers can't be executed directly. In other words, users can't simply type in an EXECUTE statement and get the trigger to run. Rather, all triggers are fired in response to data modification statements run against either tables or views.

Because there are two basic types of triggers, they are processed differently. The type of trigger that most people are familiar with is known as an AFTER trigger, because that was the type of trigger available in all versions of SQLServer before SQLServer 2000. The other type ...

Get Writing Stored Procedures for Microsoft SQL Server 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.