Answered by:
Does a Insert trigger fire when the insert is committed?

Question
-
I'm curious, does a Insert trigger fire when the insert is committed? If you could point to an article as well that would be great !
Thanks,
Dman780
Sunday, January 5, 2014 1:10 AM
Answers
-
Its depends of FOR | AFTER
FOR | AFTER
AFTER specifies that the DML trigger is fired only when all operations specified in the triggering SQL statement have executed successfully. All referential cascade actions and constraint checks also must succeed before this trigger fires.
AFTER is the default when FOR is the only keyword specified.
AFTER triggers cannot be defined on views.
For mor information : http://technet.microsoft.com/en-us/library/ms189799.aspx
Good luck
- Marked as answer by Elvis Long Monday, January 13, 2014 2:31 AM
Sunday, January 5, 2014 1:26 AM -
To add to Mahfoud's response, an after trigger fires before the an implicit transaction is committed. A rollback in a trigger will rollback the statement that fired the trigger and abort the entire batch as well.
Dan Guzman, SQL Server MVP, http://www.dbdelta.com
- Proposed as answer by Naomi N Sunday, January 5, 2014 2:13 AM
- Marked as answer by Elvis Long Monday, January 13, 2014 2:31 AM
Sunday, January 5, 2014 1:43 AM
All replies
-
Its depends of FOR | AFTER
FOR | AFTER
AFTER specifies that the DML trigger is fired only when all operations specified in the triggering SQL statement have executed successfully. All referential cascade actions and constraint checks also must succeed before this trigger fires.
AFTER is the default when FOR is the only keyword specified.
AFTER triggers cannot be defined on views.
For mor information : http://technet.microsoft.com/en-us/library/ms189799.aspx
Good luck
- Marked as answer by Elvis Long Monday, January 13, 2014 2:31 AM
Sunday, January 5, 2014 1:26 AM -
To add to Mahfoud's response, an after trigger fires before the an implicit transaction is committed. A rollback in a trigger will rollback the statement that fired the trigger and abort the entire batch as well.
Dan Guzman, SQL Server MVP, http://www.dbdelta.com
- Proposed as answer by Naomi N Sunday, January 5, 2014 2:13 AM
- Marked as answer by Elvis Long Monday, January 13, 2014 2:31 AM
Sunday, January 5, 2014 1:43 AM -
Its depends of FOR | AFTER
FOR | AFTER
AFTER specifies that the DML trigger is fired only when all operations specified in the triggering SQL statement have executed successfully. All referential cascade actions and constraint checks also must succeed before this trigger fires.
AFTER is the default when FOR is the only keyword specified.
AFTER triggers cannot be defined on views.
For mor information : http://technet.microsoft.com/en-us/library/ms189799.aspx
Sunday, January 5, 2014 3:38 AM