what are the possible reasons for 'Arithmetic overflow error converting expression to data type int' in SQL server
-- casting using DECIMAL(38,2) throws exception, Size needs to be casted as bigint


  select [SizeInMB] = CAST( ((SUM(Size)* 8) / 1024.0) AS DECIMAL(38,2) ) from sys.master_files


-- This fix is sufficient, but cannot limit to 2 decimal digits 


  select [SizeInMB1] = ((SUM(CAST(Size AS BIGINT))* 8) / 1024.0)  from sys.master_files


-- 2 decimal digits are not available in fix, as divide by 1024.0 converts to default 6 digits


  select [SizeInMB2] = ((SUM(CAST(Size AS DECIMAL(38,2)))* 8) / 1024.0)  from sys.master_files


-- so 2 casts are required to eliminate Arithmetic overflow exception and limiting 2 decimal digits


  select [SizeInMB3] = CAST( ((SUM(CAST(Size AS BIGINT))* 8) / 1024.0) AS DECIMAL(38,2) ) from sys.master_files