snippetsqlMinor
How do I find the line that causes SSMS "Msg 8115, Level 16, State 2, Line 1"
Viewed 0 times
thessmshowlinemsglevelthat8115statefind
Problem
I've got a 400 line query in MS SSMS. When I run it I get:
Msg 8115, Level 16, State 2, Line 1
Arithmetic overflow error converting expression to data type int.
Line 1 is just the "Select" statement. Is there anything I can enable in SSMS that will point me closer to the line with the error?
Msg 8115, Level 16, State 2, Line 1
Arithmetic overflow error converting expression to data type int.
Line 1 is just the "Select" statement. Is there anything I can enable in SSMS that will point me closer to the line with the error?
Solution
No.
SQL Server will just tell you the line of the statement that causes the error.
It won't even attempt to try and tie the error back to any particular line in a multiline statement and this wouldn't always be possible anyway.
For this error you likely just need to look for expressions using
For debugging purposes you can try suppressing the error with
SQL Server will just tell you the line of the statement that causes the error.
It won't even attempt to try and tie the error back to any particular line in a multiline statement and this wouldn't always be possible anyway.
For this error you likely just need to look for expressions using
SUM, COUNT or +, *, - or similar that might overflow an int (remember the problem expression could exist in the definition of any views, functions or computed columns referenced in the query too).For debugging purposes you can try suppressing the error with
SET ANSI_WARNINGS, ARITHABORT OFF; and looking for any NULL in the result that might have been an overflowed int - but that will only help if the expression causing the error relates to a column that is projected in the resultset and the problem value is not subsequently filtered out and NULL are not generally expected for that column anyway.Context
StackExchange Database Administrators Q#321593, answer score: 6
Revisions (0)
No revisions yet.