Line numbers in error messages (1 Viewer)

Zedster

Registered User
Joined
Jul 2, 2019
Messages
56
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
Joined
Oct 29, 2018
Messages
7,619
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
Joined
Jul 26, 2013
Messages
6,529
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
Joined
Jul 2, 2019
Messages
56
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
Joined
Apr 5, 2010
Messages
727
Of course in SSMS you can turn on the line numbers (normally off for some reason).
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Top Bottom