sql server - sum(DATALENGTH) returning an "Arithmetic overflow" error -
i new sql server please accept apologies if question seems easy. tried finding solution, far couldn't see use in query.
i trying find length of biggest columns in table , i'm using following query.
select sum(datalength([insdetails])) [insdetails] dbo.contractors
the table contractors
on 8gb , has on 30mln rows. insdetails
column varchar(2048)
the query above works other columns of other tables in database, when run on contractors
table returns error
msg 8115, level 16, state 2, line 26
arithmetic overflow error converting expression data type int.
i understand error message appears when try convert value of datatype datatype, value large second datatype.
could please me rewrite query or suggest alternative approach output?
i read suggested using cast big int solve issue, i'm not sure how can incorporated in query.
any suggestions appreciated. thank in advance.
select sum(cast(len([insdetails]) bigint))
Comments
Post a Comment