当我尝试在MS SQL 2005数据库上运行特定的存储过程时,我得到如下错误:
Subquery returned more than 1 value. This is not permitted when
the subquery follows =, !=, <, <= , >, >= or when the subquery
is used as an expression查询中的SP很长,并调用其他SP。这个错误显然是由SQL本身产生的,并在调用堆栈中一直向上返回,但没有提到是哪个SP或行号导致了这个问题。如何才能找出抛出错误的位置,以便更轻松地进行调试?
发布于 2008-10-29 20:49:52
使用Try/Catch block应该会给你想要的东西。
在CATCH块的作用域中,可以使用以下系统函数来获取有关导致CATCH块执行的错误的信息:
* ERROR_NUMBER() returns the number of the error.
* ERROR_SEVERITY() returns the severity.
* ERROR_STATE() returns the error state number.
* ERROR_PROCEDURE() returns the name of the stored procedure or trigger where the error occurred.
* ERROR_LINE() returns the line number inside the routine that caused the error.
* ERROR_MESSAGE() returns the complete text of the error message. The text includes the values supplied for any substitutable parameters, such as lengths, object names, or times.因此,在您的示例中,ERROR_LINE()和ERROR_PROCEDURE()应该是您想要的……
https://stackoverflow.com/questions/248354
复制相似问题