Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Arithmetic overflow error converting numeric to da

Author  Topic 

m.natarajan
Starting Member

2 Posts

Posted - 2007-08-31 : 05:52:16
Hi,

I have following set statements in my stored procedure.while running application throws "Arithmetic overflow error converting numeric to data type numeric" sql exeception.The field datatype is numeric(30,15)

DECLARE @CurLeve numeric(30,15)
set @CurLeve= (-8.659000000000000 / (-0.003999999999997 + 0.004000000000000))
print @CurLeve

I tried to convert to 30,15 but it is throwing the same exception.
Can any one on this.

Thanks,
Natarajan.M

sbalaji
Starting Member

48 Posts

Posted - 2007-08-31 : 06:19:52
As per u r eg
The maximum total number of decimal digits that can be stored, both to the left and to the right of the decimal point= 30
The maximum number of decimal digits that can be stored to the right of the decimal point=15
The maximum number of decimal digits that can be stored to the left of the decimal point = 30 - 15 = 15

The result u r getting is exceeding the limits,
so change u r datatype,as per max requirement

read OLB for max precision
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-08-31 : 07:14:24
16 digits to the left of decimal point (the division above)

-2886333333333333.3333333333333333333333



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

m.natarajan
Starting Member

2 Posts

Posted - 2007-08-31 : 08:04:46
Actually my concern is how to accommodate with in numeric(30,15).
Is there any conversion mechanisms for above query.
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-08-31 : 08:30:00
Are you familiar with logarithms?
If so, you can take
| LOG(abs(denominator)) | 
| --------------------- | (division, and then abs)
| LOG(abs(numerator)) |

If the sum is greater than 15 (numbers to the left of decimal point)
an error will occur.


E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page
   

- Advertisement -