Arithmetic overflow error converting numeric to data type numeric on Dynamic SQL

  • HI

    I am on SQL 2000 Query anaylzer and on my SP I have a Cursor with a huge Dynamic SQL statement in it and @SQL is Varchar(8000). If I run with 1 row of Data I did not get any error but If I have multiple rows I am getting the error below. Please advise. Thanks.

    Arithmetic overflow error converting numeric to data type numeric

  • When you say it works for 1 row do you mean that it works for any 1 row or one row in particular? It may be that one of the values in the rows you are selecting is throwing you off. Try isolating the row that causes the error. Since you mentioned the length of your @sql variable, are you building the string so that it handles several rows at a time or something like "select * from x where A select * from y where B" and possibly cutting off the statements? Depending on where the cut happens you may have a runnable sentence that is missing something you need.

  • Hi ksullivan

    I resolved my own problem by narrowing down that row that had given me problem and I found out the Dynamic sql has a case statement that has integer condition and return a string value that caused the error. Thanks for your help.

  • You're welcome. Good to hear you fixed it.

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply