MetricSign
Start free
Medium severitydata integrity

SQL Server Error:
8115

What does this error mean?

SQL Server raises error 8115 when an expression produces a numeric result that exceeds the range of its target data type. The full message reads: 'Arithmetic overflow error converting expression to data type [type].' This typically surfaces during SUM(), AVG(), or multiplication operations on INT, SMALLINT, or DECIMAL columns where the accumulated value outgrows the type's boundary (e.g., INT maxes out at 2,147,483,647). In data pipelines, 8115 often appears inside ADF Copy Activities, stored procedure steps, or Power BI DirectQuery refreshes — not during development, but weeks or months later when row counts or values cross a threshold. The query fails entirely; no partial result is returned.

Common causes

  • 1SUM() or COUNT() on an INT column exceeds 2,147,483,647 — common in fact tables that grow past ~2 billion rows or hold large monetary values stored as INT cents.
  • 2DECIMAL(p,s) precision is too narrow for a computed result. Example: DECIMAL(10,2) maxes out at 99,999,999.99; a SUM over a large dataset crosses that boundary.
  • 3Implicit type conversion during INSERT...SELECT or MERGE when the source expression yields a wider type than the target column allows.
  • 4A CAST or CONVERT in a WHERE clause or JOIN condition silently narrows a value — e.g., CAST(BIGINT_col AS INT) in a view that ADF queries.
  • 5Date arithmetic produces a datetime outside SQL Server's valid range (1753-01-01 to 9999-12-31), for example DATEADD(DAY, large_offset, '2020-01-01') with dirty offset values.

How to fix it

  1. 1Step 1: Identify the failing expression. Run the query in SSMS with SET ANSI_WARNINGS ON and check the error message for the target type. The execution plan's Compute Scalar or Stream Aggregate operator shows where overflow occurs.
  2. 2Step 2: Widen the aggregation input before it overflows: SELECT SUM(CAST(amount AS BIGINT)) FROM sales; — casting inside SUM prevents overflow during accumulation.
  3. 3Step 3: For DECIMAL overflows, increase precision in the expression: SELECT SUM(CAST(unit_price AS DECIMAL(18,2))) FROM order_lines; — or ALTER the column: ALTER TABLE order_lines ALTER COLUMN unit_price DECIMAL(18,2);
  4. 4Step 4: Find all INT columns at risk of overflow: SELECT TABLE_NAME, COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE DATA_TYPE = 'int' AND TABLE_SCHEMA = 'dbo'; — cross-reference with tables that hold growing counters or financial totals.
  5. 5Step 5: For date overflows, filter invalid dates before calculation: DELETE FROM staging.events WHERE event_date < '1753-01-01' OR event_date > '9999-12-31'; — or use TRY_CONVERT(datetime, event_date) IS NOT NULL in a WHERE clause.
  6. 6Step 6: In ADF, if a Copy Activity triggers 8115, open the pipeline run → Activity output → check the 'errors' array for the exact SQL statement. Fix the source query or add a pre-copy script that casts columns.
  7. 7Step 7: After fixing, add a data quality check to your pipeline that asserts MAX(col) < threshold. Example: IF (SELECT MAX(amount) FROM sales) > 2000000000 THROW 50001, 'amount approaching INT overflow', 1;

Example log output

2026-05-11T06:15:03.412Z [ERROR] Activity 'sp_load_daily_revenue' failed: Msg 8115, Level 16, State 2, Line 14
Arithmetic overflow error converting expression to data type int.
2026-05-11T06:15:03.418Z [ERROR] Pipeline 'pl_nightly_warehouse' run 9a3f2c10-4b1a-8e4d-0d5e-6f7a8b9c3a7f terminated with status Failed

Frequently asked questions

How do I find which column causes error 8115?

Run the failing query in SSMS with 'Include Actual Execution Plan' enabled. The error points to a specific line number in the batch. Look for Compute Scalar or Stream Aggregate operators in the plan — the one that fails shows the expression. Alternatively, wrap each aggregated column with TRY_CAST(col AS BIGINT) and check which one returns NULL on large values: SELECT TRY_CAST(SUM(CAST(amount AS BIGINT)) AS INT) FROM sales; — a NULL result means that column overflows.

Can Power BI DAX cause error 8115?

In DirectQuery mode, yes. DAX measures like SUMX or CALCULATE generate SQL that runs on your SQL Server — if the underlying column is INT and the aggregation overflows, SQL Server raises 8115 and the visual or refresh fails. In Import mode, Power BI uses the VertiPaq engine which handles 64-bit integers natively, so 8115 won't occur there.

Does SQL Server retry after error 8115?

No. Error 8115 is a deterministic data-type error, not a transient failure. Retrying the same query with the same data produces the same error. ADF retry policies won't help. The fix is to widen the data type or filter the values causing overflow before aggregation.

Should I change the column type or just cast in the query?

If the column regularly holds values near the type boundary, ALTER the column to BIGINT or a wider DECIMAL — this prevents 8115 everywhere the column is used. If only one specific aggregation overflows (e.g., a SUM across millions of rows where individual values are small), casting in the query is sufficient: SUM(CAST(col AS BIGINT)). Changing the column type requires checking foreign keys, indexes, and dependent views.

Source · learn.microsoft.com/en-us/sql/relational-databases/errors-events/mssqlserver-8115-database-engine-error

Other data integrity errors