Fix: Arithmetic Overflow Error Converting Expression to Data Type INT
If the integer value exceeds certain value, you'll get this error
3 min. read
Updated on
Read our disclosure page to find out how can you help Windows Report sustain the editorial team. Read more
Key notes
- To fix arithmetic overflow errors, you need to convert results from int to big int data type.
- Alternatively, you can convert the entire column to big int type in order to avoid the error.
An arithmetic overflow error converting expression to data type int is an SQL error, and if it occurs, your query won’t be executed, thus preventing you from obtaining your data.
As a result, certain parts of your app won’t work correctly, and this can cause additional problems. Therefore, it’s essential to fix this issue immediately, and in this guide, we will show you the best ways to do it.
What is an arithmetic overflow error converting expression to data type int?
This error indicates that a SQL value is too large and can’t be handled by an integer data type. If your value is larger than 2,147,483,647, the integer data type won’t be able to process it, and you’ll get the error above.
How do I fix arithmetic overflow error converting expression to data type int?
1. Convert the value to bigint
- Open your code.
- Use the following code:
SELECT SUM(CAST(balance AS bigint)) FROM Accounts;
- Save changes.
With the CAST command, you’ll convert the results from an integer to a big integer data type.
2. Alter the entire column
- Open the SQL shell.
- Now run the following commands:
ALTER TABLE your_table_name
ALTER COLUMN balance BIGINT; - Save changes.
Using these commands, you’ll change the data type of the entire column from int to big int, thus increasing the maximum supported value.
3. Replace count with count_big
- Open your code.
- Next, locate the count line, it should look like this:
count(*) as count
- Replace it with the following:
count_big(*) as count
- Save the changes.
Arithmetic overflow error converting expression to data type int, the statement has been terminated error will cause your application to crash, since your variables are too big, but that can be quickly resolved by converting them, the same way as it works for the other overflow errors.
Server errors can be severe, and we already covered 0x80040e14 SQL Server error in one of our earlier guides. An incompatible OS can also cause problems with SQL, and many users reported that the operating system is not supported by SQL Server messages.
These errors can sometimes lead to database corruption, and if you ever encounter this issue, we have a guide on how to repair a corrupted database in SQL Server.
Did you ever encounter an Arithmetic overflow error converting expression to data type int in SQL Server, and how did you fix it? Let us know in the comments below!
User forum
0 messages