SQLTeam.com | Weblogs | Forums

Arithmetic overflow issue


#1

hi team ,
following select is giving error when i tried to execute it.

select 85509560*100

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

please help to resolve the issue and reason behind it.


#2

integer is 4 bytes, max value is 2,147,483,647
https://msdn.microsoft.com/en-us/library/ms187745.aspx

when you multiply an integer with another integer, the result will also be in integer. For your computation the result exceed the max value of integer

just convert one of them to bigint and the result will be bigint and it will hold the computed value

select 8550*95*60*convert(bigint, 100)