Fix: Arithmetic Overflow Error Converting Expression to Data Type INT

If the integer value exceeds certain value, you'll get this error

Reading time icon 3 min. read


Readers help support Windows Report. We may get a commission if you buy through our links. Tooltip Icon

Read our disclosure page to find out how can you help Windows Report sustain the editorial team. Read more

arithmetic overflow error converting expression to data type int dateadd

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

  1. Open your code.
  2. Use the following code:
    SELECT SUM(CAST(balance AS bigint)) FROM Accounts;
  3. 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

  1. Open the SQL shell.
  2. Now run the following commands:
    ALTER TABLE your_table_name
    ALTER COLUMN balance BIGINT;

  3. 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

  1. Open your code.
  2. Next, locate the count line, it should look like this: count(*) as count
  3. Replace it with the following: count_big(*) as count
  4. 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.

We also have a new guide on Error Arithmetic Overflow, so don’t miss it for more information.

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!

More about the topics: sql server

User forum

0 messages