Arithmetic overflow error converting expression to data type smallmoney
Posted on 2009-02-12
I have a stored procedure that has been running fine for serveral month, and appears to run fine for most cases for rows processed, but is blowing up with the arithmentic overflow consistently at the same point. The function calculated interest and adds interest and contributions to a balance for some number of contributions (payments). Here is the code:
declare @amount smallmoney,
set @balance = @balance + @interest + @amount
To debug, I print balance, interest and amount for each iteration. When they have the following values:
I get the error:
Msg 8115, Level 16, State 2, Line 160
Arithmetic overflow error converting expression to data type smallmoney.
Note, the "@balance = @balance + @interest + @amount" is line 160.
None of these values seem to exceed the smallmoney range. What's up? This is preventing us from printing payroll checks!!!!