News

Copyright © 2008-2018 Paula DiTallo

Tag Cloud



Sql Server: Select Count(*) throws the error: Arithmetic overflow error converting expression to data type int

Try using count_big(*) instead-- this is defined as bigint instead of int.

In this example, I am looking for how many 100s of millions of rows exist by product type where each row is roughly 300 bytes wide to ultimately obtain how many gigabytes of data I need to provision.

select x.ProductType,
       count_big(*) as ProdCount,
      (count_big(*)*300) as TotalBytes,
      ((count_big(*)*300)/1073741824) as Gigabytes
 from fdwintegration.etl.fuelpriceindex x
  inner join fdwintegration.etl.FuelProducts y
   on x.ProductIndicator = y.ProductIndicator
    and x.ProductType = y.ProductType
   where x.ProductIndicator = 'D'
   group by x.ProductType
order by x.ProductType
Monday, April 21, 2014 5:01 PM

Feedback

# re: Sql Server: Select Count(*) throws the error: Arithmetic overflow error converting expression to data type int

Nice share, love it. Thanks for the information. Jilbab Online 4/29/2014 5:08 AM | niceir

Post A Comment
Title:
Name:
Email:
Comment:
Verification: