8134: Divide by zero error encountered
SQL ServerWhat does it mean?
A divide-by-zero error occurred because the divisor in an arithmetic expression is zero. SQL Server cannot complete the division and stops the query.
Why does it happen?
A column or expression used as the divisor evaluates to 0, a zero denominator in average/ratio calculations, division without NULLIF, or unexpected zero values in the data.
How to fix it
Guard the denominator with NULLIF (e.g. value / NULLIF(denominator, 0)); the result becomes NULL and a default can be supplied with ISNULL/COALESCE. Use CASE WHEN denominator = 0 THEN NULL ELSE value/denominator END. Filter out zero values with WHERE before dividing. If needed, evaluate SET ARITHABORT/ANSI_WARNINGS behavior.
More from this engine
- 701There is insufficient system memory in resource pool to run this query
- 845Time-out occurred while waiting for buffer latch
- 3201Cannot open backup device. Operating system error (backup device error)
- 245Conversion failed when converting the value to data type
- 515Cannot insert the value NULL into column
- 8115Arithmetic overflow error converting expression to data type
- 512Subquery returned more than 1 value