Specifying When a Trigger Fires
SQL Server 2000
You can specify one of two options to control when a trigger fires:
- AFTER triggers fire after the triggering action (INSERT, UPDATE, or DELETE),INSTEAD OF triggers and constraints are processed. You can request AFTER triggers by specifying either the AFTER or FOR keywords. Because the FOR keyword has the same effect as AFTER, triggers with the FOR keyword are also classified as AFTER triggers.
- INSTEAD OF triggers fire in place of the triggering action and before constraints are processed. If there are AFTER triggers on the table, they will fire after constraint processing. If the constraints are violated, the INSTEAD OF trigger actions are rolled back and the AFTER trigger is not executed.
Each table or view can have one INSTEAD OF trigger for each triggering action (UPDATE, DELETE, and INSERT). A table can have several AFTER triggers for each triggering action.
A. Use the INSTEAD OF trigger to replace the standard triggering action
CREATE TRIGGER TableAInsertTrig ON TableA INSTEAD OF INSERT AS ...
B. Use the AFTER trigger to augment the standard triggering action
CREATE TRIGGER TableBDeleteTrig ON TableB AFTER DELETE AS ...
C. Use the FOR trigger to augment the standard triggering action
-- This statement uses the FOR keyword to generate an AFTER trigger. CREATE TRIGGER TableCUpdateTrig ON TableC FOR UPDATE AS ...