我使用的是SQL Server 2014;我的存储过程将是嵌套事务过程,它将调用很少有事务的存储过程。如果任何一个内部存储过程都遇到错误,则将回滚所有,如
Begin Try
Begin Tran
Exec Stored Proc 1 (with begin tran inside)
Exec Stored Proc 2 (with begin tran inside)
Exec Stored Proc 3 (with begin tran inside)
Exec Stored Proc 4 (with begin tran inside)
Exec Stored Proc 5 (with begin tran inside)
Commit Tran
End Try
Begin Catch
Catch exception then roll back tran
End Catch问题是执行内部存储过程后的事务计数不匹配,但是如果我没有在内部存储过程中打开事务,它就不会回滚。有人能给我一些建议吗?
发布于 2017-06-05 04:18:53
SQL Server数据库引擎忽略提交内部事务。事务是根据在最外层事务结束时采取的操作提交或回滚的。如果提交了外部事务,则内部嵌套事务也将提交。
https://stackoverflow.com/questions/44360877
复制相似问题