Line numbers in error messages

Zedster

Registered User.
Local time
Today, 18:22
Joined
Jul 2, 2019
Messages
169
I am getting an error message:

Msg 8152, Level 16, State 10, Line 16
String or binary data would be truncated.


I believe it is occurring in a stored Scalar-Valued function that is being called from a query.

How do I find line 16 because:

  • lines have spaces
  • There are comments
  • To view the function I need to modify it and that includes the code to instruct the alteration
 
Last edited:
Hi. I'm just guessing here but I think the comments and empty lines count but not sure about the ALTER line though. Would you be able to do a quick experiment and create a small function that raises an error. You can then add empty and comment lines to see if the line number reported when the error occurs matches what you're expecting to get.
 
If that is in the query window in SSMS you can normally double click on the error and it will take you to the offending line ?

Caveat : This may be version dependent
 
If that is in the query window in SSMS you can normally double click on the error and it will take you to the offending line ?

Caveat : This may be version dependent

Having just tried that I can confirm that for SSMS V18.2 double clicking the error works, thank you.
 
Last edited:
Of course in SSMS you can turn on the line numbers (normally off for some reason).
 

Users who are viewing this thread

Back
Top Bottom