Home > Articles > Data

  • Print
  • + Share This
This chapter is from the book

Trigger Utilization

Triggers are like stored procedures in that they contain a set of T-SQL statements saved for future execution. The big difference is that, unlike stored procedures, triggers are executed automatically based on data activity in a table. A trigger may fire based on UPDATE, INSERT, or DELETE operations.

In SQL Server 2000, triggers can be fired after an operation completes (SQL Server default) or instead of the triggering operation. An AFTER trigger can be used to archive data when it is deleted, to send a notification that the new data has been added or changed, or to initiate any other process you might want to automate based on data activity. An INSTEAD OF trigger can be used to perform more advanced activities (such as advanced data checking), to enable updates in a view to occur across multiple tables, and to perform many other functions that might be necessary in place of a triggering activity.

Triggers represent a mechanism in which code can be executed based on activity in the data. Triggers are expanded on and fully illustrated in Chapter 6.

  • + Share This
  • 🔖 Save To Your Account