A trigger is a mechanism that is invoked when a particular action occurs on a particular table. Each trigger has three general parts:A nameThe actionThe executionThe maximum size of a trigger name is 128 characters. The action of a trigger … [Read more...] about Triggers an Introduction, Creating a DML Trigger
Triggers
This chapter is dedicated to a mechanism called a trigger. The beginning of the chapter describes Transact-SQL statements for creating, deleting, and modifying triggers. After that, examples of different application areas for DML triggers are given. Each example is created using one of three statements, INSERT, UPDATE, or DELETE. The second part of the chapter covers DDL triggers, which are based on DDL statements such as CREATE TABLE. Again, examples of different application areas related to DDL triggers are given. The end of the chapter discusses the implementation of triggers using CLR (Common Language Runtime).
After Triggers
As you already know, AFTER triggers fire after the triggering action has been processed. You can specify an AFTER trigger by using either the AFTER or FOR reserved keyword. AFTER triggers can be created only on base tables.AFTER triggers can be … [Read more...] about After Triggers
INSTEAD OF Triggers
A trigger with the INSTEAD OF clause replaces the corresponding triggering action. It is executed after the corresponding inserted and deleted tables are created, but before any integrity constraint or any other action is performed.INSTEAD OF … [Read more...] about INSTEAD OF Triggers
First and Last Triggers
The Database Engine allows multiple triggers to be created for each table or view and for each modification action (INSERT, UPDATE, and DELETE) on them. Additionally, you can specify the order of multiple triggers defined for a given action. Using … [Read more...] about First and Last Triggers
DDL Triggers and Their Application Areas
The first part of this chapter described DML triggers, which specify an action that is performed by the server when a modification of the table using an INSERT, UPDATE, or DELETE statement is executed. The Database Engine allows you to define … [Read more...] about DDL Triggers and Their Application Areas
Triggers and CLR
Triggers, as well as stored procedures and user-defined functions, can be implemented using the Common Language Runtime (CLR). The following steps are necessary if you want to implement, compile, and store CLR triggers:Implement a trigger using … [Read more...] about Triggers and CLR