标签:
Throw 命令没有Exception severity 参数,The exception severity is always set to 16.
Raises an exception and transfers execution to a CATCH block of a TRY…CATCH construct in SQL Server 2012.
THROW [ { error_number | @local_variable }, { message | @local_variable }, { state | @local_variable } ] [ ; ]
Arguments
Remarks
If a TRY…CATCH construct is not available, the session is ended. The line number and procedure where the exception is raised are set. The severity is set to 16.
If the THROW statement is specified without parameters, it must appear inside a CATCH block. This causes the caught exception to be raised. Any error that occurs in a THROW statement causes the statement batch to be ended.
State的作用:如果在多个位置引发相同的用户自定义错误,则针对每个位置使用唯一的状态号有助于找到引发错误的代码段。
Examples
THROW 51000, ‘The record does not exist.‘, 1;
参考文档:
标签:
原文地址:http://www.cnblogs.com/ljhdo/p/5665088.html