Skip to content Skip to sidebar Skip to footer

How To Solve Msg 8115, Level 16, State 2, Line 2 Arithmetic Overflow Error Converting Expression To Data Type Int.?

I have a formula like this. But the formula has an error. Please help me. select [DAY] as [DAY], [Name] as [Name], ((cast([columnA] + [columnB] + [columnC] as bigint)

Solution 1:

Since your dividend is a bigint I suspect you will need the divisor to also be a bigint. Since you have some integer literals the math will attempt to put that in an int and it is too large. You can however force the divisor to be a bigint.

convert(bigint, 8) * 1024 * 1048576

Solution 2:

I am not sure what you are trying at your end, but you can use NUMERIC datatype as the results can contain decimal places.

select'Monday'as [DAY],
'Septiana Fajrin'as [Name],
((cast('5'+'5'+'5'asNumeric) *1000) / (convert(Numeric, 8) *1024*1048576))as [TotalColumn]  

Result

DAY Name    TotalColumn
Monday  Septiana Fajrin 0.000064610503613

Post a Comment for "How To Solve Msg 8115, Level 16, State 2, Line 2 Arithmetic Overflow Error Converting Expression To Data Type Int.?"