问题描述
调用此代码的客户端受到限制,只能处理来自存储过程的返回代码.因此,我们将通常的合约修改为 RETURN -1
出错,default 修改为 RETURN 0
如果没有错误
The client that calls this code is restricted and can only deal with return codes from stored procs. So, we modified our usual contract to RETURN -1
on error and default to RETURN 0
if no error
如果代码命中内部 catch 块,则返回代码默认为 -4 而不是 0
If the code hits the inner catch block, then the RETURN code default is -4 rather then 0
请问有大佬知道出处吗?参考
Does anyone know where this comes from please? With reference
干杯英镑
推荐答案
在玩弄这个过程时,如果我在 foo.KeyCol 中插入一个 null 并删除内部 catch 中的 RAISERROR,我可以得到一个返回值 -6.这是 SQL Server 正在做的事情,并记录在此处:Return Values from Stored Procedures.
In playing around with the procedure, I can get a a return -6, if I insert a null into foo.KeyCol and remove the RAISERROR in the inner catch. This is something SQL Server is doing, and is documented here: Return Values from Stored Procedures.
这篇关于SQL Server 存储过程返回码奇怪的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!