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 2000 Forums
 Transact-SQL (2000)
 SUM fails

Author  Topic 

dcarva
Posting Yak Master

140 Posts

Posted - 2007-01-29 : 10:21:54
Hello,

I use the SUM function to add up columns. However, sometimes the values being added add up to a number that is too large for the SUM function to handle. I get this error:

Arithmetic overflow error converting expression to data type int.

If I reduce the amount I am adding, then it works ok. I know it's a big number, but I still have to add it up. Is there another function I could use that would sum up to a type that is larger than int? I didn't see anything in the SQL Help.

Thanks!
Danny

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-01-29 : 10:23:08
sum(cast(mycolumn) as bigint)


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

dcarva
Posting Yak Master

140 Posts

Posted - 2007-01-29 : 10:30:47
Thanks! I should have thought of that.
Go to Top of Page
   

- Advertisement -