解决方法
Kalen Delaney has an article covering the same type of behavior that you describe.
然而,正如Kalen的文章所述,嵌套事务中的ROLLBACK将回滚整个外部事务,而不仅仅是回滚发生的内部事务.
请注意以下结果:
BEGIN TRAN SELECT @@trancount BEGIN TRAN SELECT @@trancount BEGIN TRAN SELECT @@trancount ROLLBACK TRAN SELECT @@trancount
这在MSDN文章Nesting Transactions中有描述:
A ROLLBACK WORK or a ROLLBACK TRANSACTION statement that does not have a transaction name rolls back all nested transactions and decrements @@TRANCOUNT to 0. A ROLLBACK TRANSACTION that uses the transaction name of the outermost transaction in a set of nested transactions rolls back all of the nested transactions and decrements @@TRANCOUNT to 0. When you are unsure if you are already in a transaction,SELECT @@TRANCOUNT to determine if it is 1 or more. If @@TRANCOUNT is 0,you are not in a transaction.
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。