Return value from a stored proc on error

前端 未结 5 1662
灰色年华
灰色年华 2020-12-09 09:24

I have an sp in SQL Server that when errors returns -4

What does -4 mean? Is there a table somewhere explaining what the possible return values are?


Th

5条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-09 09:41

    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.

    As you may guess this is not terribly useful, but this: 0 is success, and everything else is an error.

提交回复
热议问题