Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Arithmetic overflow error when summing an INT, how do I cast it as a BIGINT?

People also ask

How to resolve Arithmetic overflow error converting expression to data type int?

The solution to avoid Arithmetic overflow error converting expression is to use a bigger data type. The solution to avoid this arithmetic overflow error is to change the data type from INT to BIGINT or DECIMAL(11,0) for example.

How do you fix an arithmetic overflow error?

You need to increase the width of the variable to store this number e.g. making @sample NUMERIC (6,2) will solve this error.

What does arithmetic overflow error convert to data type int mean?

1. "Arithmetic overflow error converting IDENTITY to data type int" error means the value of IDENTITY is overflowing range of data type of that particular column. 2. Check the current value of Identity.


Try converting it before summing. eg.

SELECT SUM(CONVERT(bigint, columnname)) FROM tablename

or

SELECT SUM(CAST(columnname AS BIGINT)) FROM tablename