Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SELECT SUM causes error 1

Status
Not open for further replies.

limester

Technical User
Dec 29, 2004
69
CA
Hi There,

When trying to run a query:

select sum(col1) from table

I get the following error:

Server: Msg 8115, Level 16, State 2, Line 1
Arithmetic overflow error converting expression to data type int.

Is there anyway to avoid this to get the results I need?

Thanks!
 
col1 must not be an integer data type. You could try this...

select sum(Convert(bigint, col1)) from table

If col1 is a varchar column, this may also fail due to conversion errors.



-George

"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
excellent! thanks gmmastros!

I knew I needed to convert the int datatype was wasn't aware bigint existed!

Cheers!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top