Line numbers in error messages (1 Viewer)

Zedster

Registered User.
Local time
Today, 20:33
Joined
Jul 2, 2019
Messages
168
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:

theDBguy

I’m here to help
Staff member
Local time
Today, 13:33
Joined
Oct 29, 2018
Messages
21,358
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.
 

Minty

AWF VIP
Local time
Today, 20:33
Joined
Jul 26, 2013
Messages
10,355
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
 

Zedster

Registered User.
Local time
Today, 20:33
Joined
Jul 2, 2019
Messages
168
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:

kevlray

Registered User.
Local time
Today, 13:33
Joined
Apr 5, 2010
Messages
1,046
Of course in SSMS you can turn on the line numbers (normally off for some reason).
 

Users who are viewing this thread

Top Bottom