SQL Server: how to find the specific line of failing code based on [Batch Line Start] error

a64a0gku  于 2023-04-19  发布在  SQL Server
关注(0)|答案(2)|浏览(129)

Often while running procedures in Microsoft SQL Server, I will get an error message like the following:
Msg 8114, Level 16, State 5, Procedure XYZ, LineAss 88 [Batch Start Line 2]

However, Line 88 as specified in LineAss 88 won't actually contain any code related to the error. Also it is typically unclear what Batch Line Start # refers to.

What methodology do you use based on the batch and line number to actually identify the specific code that is the problem when debugging failing procedures?

rks48beu

rks48beu1#

Took me a while to understand your question completely. The line number mentioned in the error message does not point to the exact line in which error occurred. It points to the statement in which the error occurred. Another thing to note is that, in your stored procedure, if you have blank rows at the beginning of the query, they will be added into the line count. This sometimes throws off the line number which you see in the error message as well.

I also found an interesting read on this topic:

http://tomaslind.net/2013/10/15/line-numbers-in-t-sql-error-messages/

This should be able to clarify most of your doubts. Let me know if you need further clarifications.

mnowg1ta

mnowg1ta2#

Do "Alter definition" It seems to start from the GO line in the Stored Proc is line Zero

EG I got an error Msg 1205, Level 13, State 78, Procedure dbo.xxx, Line 678 [Batch Start Line 2]

Go was line 7 and when I tracked it down, it was line 600 in the file.

相关问题