Wrong Line Number reported in SQL Message Window

I am getting the following message when I run a procedure in SQL
Msg 8626, Level 16, State 1, Line 10

My script has over a 1000 lines of SQL in it and the message in not related to line 10 of the script.  Any suggestions on how to get the actual line number for the message?
Who is Participating?
Anthony PerkinsCommented:
As I stated before the Line Number is relative, so you may think this is wrong. but if you have something like this:
SELECT * FROM ValidTable

What do you think the line number for the error "Divide by zero error encountered" should be?  If you thought it should be 3, you would be wrong.  It is 0.

Here is what I suggest you do as a technique for debugging.  Next time you get an error, ignore the line number, especially if you are using GO command, but instead double click on the error.  It will take you to the line that generated the specific error.
Anthony PerkinsCommented:
The line number is always relative and closest to the start of the query with the error.

Try posting the relevant part of the code, the error message and we may be able to help you more.
bkjennerAuthor Commented:
I wasnt so much looking help with the error message but more wondering how when you have a long sql script with multiple GO statements in it, how can you easily determine the line number for error messages.
bkjennerAuthor Commented:
Thanks for your help! Works great
Anthony PerkinsCommented:
And this:
It is 0.
Should of course have read:
It is 1.

Thanks for the points.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.