SQL Server Triggers Question:
Explain trigger classes i.e. instead of and after trigger?
Answer:
INSTEAD OF: Cause the trigger to fire instead of executing the triggering event or action. It prevents unnecessary changes to be made.
Example: Causes the trigger to fire instead of the update (action)
CREATE TRIGGER Employee_update ON Employee INSTEAD OF UPDATE AS { TRIGGER Definition }
AFTER: execute following the triggering action, such as an insert, update, or delete. These triggers are fired a little late in the process.
Example: Causes the trigger to fire instead of the update (action)
CREATE TRIGGER Employee_update ON Employee AFTER UPDATE AS { TRIGGER Definition }
Example: Causes the trigger to fire instead of the update (action)
CREATE TRIGGER Employee_update ON Employee INSTEAD OF UPDATE AS { TRIGGER Definition }
AFTER: execute following the triggering action, such as an insert, update, or delete. These triggers are fired a little late in the process.
Example: Causes the trigger to fire instead of the update (action)
CREATE TRIGGER Employee_update ON Employee AFTER UPDATE AS { TRIGGER Definition }
Previous Question | Next Question |
How to apply cascading referential integrity in place of triggers? | What are the instances when triggers are appropriate? |