October 18, 2025 at 12:30 am
Hi everyone
I have a 1000 plus line query and I am getting an error:
Msg 8115, Level 16, State 6, Procedure dbo.TestQuery, Line 1036 [Batch Start Line 2]
Arithmetic overflow error converting float to data type numeric.
It says line 1036 but when I go to that line I get something that can't possible cause an error. Line 1036 is part of a comment.
Is there a way to know the actual line that caused the failure? That way I can troubleshoot the issue.
Thank you
October 19, 2025 at 1:10 am
Thanks for posting your issue and hopefully someone will answer soon.
This is an automated bump to increase visibility of your question.
October 20, 2025 at 9:58 pm
I think you need to ignore the header piece with the CREATE statement, and start the line numbering at the top of the actual procedure code
October 21, 2025 at 9:14 am
also note that if a long statement is in use, like WITH MyCTE..... or a cursor, the error returns the first line of the statement, and not the in between line where the error actually occurred, you'll want to break down the offending query, but you should be able to find any column or calculation that would return a float, right? and explicitly cast it if needed?
Lowell
October 23, 2025 at 3:51 pm
If this is in SSMS, I often double click the error and it jumps to the line, which usually gets me close enough to figure out what is wrong.
The other thing you might try is pasting this into an LLM (if you are allowed), which might spot a syntax error
October 26, 2025 at 11:12 pm
This is a classic problem with where to start counting. It's compounded by the fact that when people generate the code for modification, it frequently adds a blank line above the CREATE statement.
--Jeff Moden
Change is inevitable... Change for the better is not.
November 3, 2025 at 8:11 am
I use the (undocumented) LINENO command when testing my stored procedures. This makes the line reported in the error correspond more exactly to the code.

Viewing 7 posts - 1 through 7 (of 7 total)
You must be logged in to reply to this topic. Login to reply