我有一个没有问题的存储过程,即返回码为0.在某些情况下,我RAISERROR是用户定义的错误(> 50000).在这些情况下,回报是-6.我只是好奇,-6是什么意思?我没有在过程中设置返回码,所以这个号码是SQL Server(系统)生成的.
我发现这句话:
Whether these negative numbers have any meaning,is a bit difficult to tell. It used to be the case,that the return values -1 to -99 were reserved for system-generated return values,and Books Online for earlier versions of SQL Server specified meanings for values -1 to -14. However,Books Online for SQL 2000 is silent on any such reservations,and does not explain what -1 to -14 would mean.
有谁知道这些返回码的“隐藏”含义?
我正在使用SQL Server 2008 R2.
解决方法
好的,我发现了……
Return value from a stored proc on error
If you have a RETURN statement with an explicit return value,that is of course the return value.
But if there is no RETURN statement,but an error occurs during execution,the return value is 10 minus the severity level of the error. Division by zero is level 16,thus the return value is -6. Permissions errors are typical level 14,thus the return value is -4.
在我的情况下,我提出的错误的严重性是16,所以10 – 16 = -6.
感谢大家的投入.
(编辑:李大同)
【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!
|