I read that SQL exceptions are treated as normal exceptions in managed SPs; I would like to know how is following scenario handled w.r.t to this.
我读到SQL异常在托管SP中被视为普通异常;我想知道以下场景如何处理w.r.t。
- I have a normal t-SQL SP that calls a managed SP.
- managed SP throws exception due to some issue.
- How does normal T-SQL handle this.
我有一个普通的t-SQL SP调用托管SP。
由于某些问题,托管SP抛出异常。
普通的T-SQL如何处理这个问题。
I have not tried this scenario yet as I do not have SQL server on my current machine.
我还没有尝试过这种情况,因为我当前的机器上没有SQL服务器。
1 个解决方案
#1
It handles it like any other exception. In your TSQL code, you can wrap the call in a Try-Catch block.
它像任何其他异常一样处理它。在您的TSQL代码中,您可以将调用包装在Try-Catch块中。
For example:
Begin Try
exec myManagedProc
End Try
Begin Catch
print 'Error:' + error_message()
End Catch
#1
It handles it like any other exception. In your TSQL code, you can wrap the call in a Try-Catch block.
它像任何其他异常一样处理它。在您的TSQL代码中,您可以将调用包装在Try-Catch块中。
For example:
Begin Try
exec myManagedProc
End Try
Begin Catch
print 'Error:' + error_message()
End Catch