简体   繁体   English

SQL 服务器返回码-6,是什么意思?

[英]SQL Server return code -6, what does it mean?

I have a stored procedure that works with no issues, that is the return code is 0. In some cases I RAISERROR a user defined error (> 50000).我有一个可以正常工作的存储过程,即返回码为 0。在某些情况下,我 RAISERROR 是用户定义的错误(> 50000)。 In those cases the return is -6.在这些情况下,回报是-6。 I am just curious, what does -6 mean?我只是好奇,-6是什么意思? I do not set the return code in the procedure, so this number is SQL Server (system) generated.我没有在程序中设置返回码,所以这个数字是SQL 服务器(系统)生成的。

I found this statement:我发现了这个说法:

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.过去的情况是,返回值 -1 到 -99 是为系统生成的返回值保留的,而早期版本的 SQL 服务器的联机丛书为值 -1 到 -14 指定了含义。 However, Books Online for SQL 2000 is silent on any such reservations, and does not explain what -1 to -14 would mean.但是,SQL 2000 的在线图书对任何此类保留都保持沉默,也没有解释 -1 到 -14 的含义。

Does anyone know the "hidden" meanings to these return codes?有谁知道这些返回码的“隐藏”含义?

I am using SQL Server 2008 R2.我正在使用 SQL Server 2008 R2。

OK, I found this...好吧,我找到了这个……

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.但是如果没有 RETURN 语句,但执行过程中发生错误,则返回值为 10 减去错误的严重级别。 Division by zero is level 16, thus the return value is -6.除以零是第 16 级,因此返回值为 -6。 Permissions errors are typical level 14, thus the return value is -4.权限错误是典型的 14 级,因此返回值为 -4。

In my case, the severity of the error I was raising was 16, so 10 - 16 = -6.就我而言,我提出的错误的严重程度是 16,所以 10 - 16 = -6。

Thanks everyone for thier input.感谢大家的意见。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM