patternsqlModerate
Is there a way to ensure that a SQL Server trigger will be executed?
Viewed 0 times
triggersqlwayensureexecutedwillthatserverthere
Problem
My supervisor is hesitant to use a trigger in a process because if there is a network interruption at just the right time, the process would not complete. Does SQL Server include the trigger in the calling procedure's transaction? If not, what is the best way to implement this?
Solution
Yes. Triggers occur as an implicit nested transaction within the scope of the caller's transaction. The trigger will commit or roll back as part of this transaction.
See:
See:
- Nesting Transactions
- Rollbacks and Commits in Stored Procedures and Triggers
- ROLLBACK TRANSACTION (Transact-SQL)
Context
StackExchange Database Administrators Q#10167, answer score: 12
Revisions (0)
No revisions yet.