964
Views
5
Comments
How to fix : Arithmetic overflow error converting numeric to data type numeric. 
Question

Sir,

Please check below mentioned error:





2018-09-27 18-20-33
Swatantra Kumar
Champion

Hi Amit,

The conversion is failing as it looks like you're trying to cast / convert a number, pretty big number to the small allowed window.

Basically the decimal(p,s) and numeric(p,s) both specify a Precision and a Scale. Check what are the limits in your data model and what conversion is happening with this operation.

2018-09-27 18-20-33
Swatantra Kumar
Champion

You may solve the issue by adjusting the size of Scale or precision (depends, what is causing error).

2022-04-20 12-08-36
Soundarya

iamuramit wrote:

Sir,

Please check below mentioned error:





Hi ,

    Are you using any sql QUERY CONVERSION  of integer to numeric datatype or else it been a expreesion overflow error of outsystems.

Refer This if its related to you issues or else, Please explain query in detail manner

https://www.codeproject.com/Questions/367195/Arithmetic-overflow-error-converting-numeric-to-da

https://success.outsystems.com/Documentation/11/Reference/Errors_and_Warnings/Errors/Expression_Overflow_Error


Thanks 

soundarya


2019-01-31 08-54-57
André Costa
Champion


Your problem can be fixed by defining the "Lenght" property of your attribute to be greater than "Decimals" property since you must have always the whole-number part of your decimalThe whole-number part 

Don't forget to mark an answer as correct so we can help the community to find a solution faster.

2024-01-04 09-21-21
Venkatesaiya

I know it's too late, but this might be helpful for other developers who face the same issue in the future 

The "Arithmetic overflow error converting expression to data type int" error in an advanced query indicates that a numerical value is being processed or stored in a way that exceeds the maximum capacity of the INT data type. This typically occurs in SQL Server environments but can manifest in other contexts where data type limitations are encountered.

Here are the common causes and solutions:

Exceeding INT Limit: The most frequent cause is a calculation or a value that results in a number larger than the maximum value an INT can hold (which is 2,147,483,647). This can happen in aggregate functions like SUM() or COUNT(), or when dealing with large identity columns.

Solution:

Change Data Type to BIGINT: If the values or results of calculations are expected to exceed the INT limit, change the data type of the affected column(s) or variables to BIGINT. BIGINT can store much larger numbers (up to 9,223,372,036,854,775,807).


Refer these pattern based on your query:
    -- Example with SUM

    SELECT SUM(CAST(YourIntColumn AS BIGINT)) AS TotalValue

    FROM YourTable;


    -- Example with a calculation

    SELECT CAST(ColumnA * ColumnB AS NUMERIC(18, 0)) AS CalculatedValue

    FROM YourTable;

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.