Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Arithmetic overflow Expand / Collapse
Author
Message
Posted Wednesday, April 8, 2009 1:31 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Friday, June 12, 2009 8:16 AM
Points: 38, Visits: 129
Hello,

when I try the following sql I get an error:

select sum(datalength(memTest))
from tblTest

Arithmetic overflow error converting expression to data type int


Has anyone an idea?

Thanks.
Post #692812
Posted Wednesday, April 8, 2009 1:58 AM


UDP Broadcaster

UDP BroadcasterUDP BroadcasterUDP BroadcasterUDP BroadcasterUDP BroadcasterUDP BroadcasterUDP BroadcasterUDP Broadcaster

Group: General Forum Members
Last Login: Today @ 9:12 AM
Points: 1,483, Visits: 8,552
Hi,

According to BOL, DataLength returns either an int or bigint depending upon the type of the field it is examining. So what is the definition of 'memTest' and how many rows are there?
It could be that it is going to return an int, but the accumulated value is too large for such a field.

BrainDonor


BrainDonor
Linkedin
Blog Site
Post #692827
Posted Wednesday, April 8, 2009 2:26 AM


Mr or Mrs. 500

Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500

Group: General Forum Members
Last Login: Monday, May 9, 2011 2:49 AM
Points: 536, Visits: 412
Try this,

select sum(Convert(bigint,datalength(memTest),0))
from tblTest


"Don't limit your challenges, challenge your limits"
Post #692834
Posted Wednesday, April 8, 2009 3:46 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Friday, June 12, 2009 8:16 AM
Points: 38, Visits: 129
Thanks kruti, it works.
Post #692890
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse