我正在使用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
问题是执行内部存储过程后的事务计数不匹配,但如果我在内部存储过程中没有开启事务,则不会回滚。有人可以给我一些建议吗?