SET NUMERIC_ROUNDABORT

SET NUMERIC_ROUNDABORT#

Specifies the level of error reporting generated when rounding in an expression causes a loss of precision.

Syntax#

SET NUMERIC_ROUNDABORT { ON | OFF }  [;]

Remarks#

When SET NUMERIC_ROUNDABORT is ON, an operation that has to reduce a decimal value’s scale to fit its result type raises error 8115 (Arithmetic overflow error converting numeric to data type numeric.) instead of rounding the value away. This affects multiplication, division, and a down-scaling CAST or CONVERT between decimal / numeric types, whenever the declared result scale is lower than the operation’s natural scale. For example CAST(6 AS decimal(38,0)) / CAST(2 AS decimal(38,0)) must clamp the division scale from 39 down to 6, so it raises even though 6 / 2 is exact. The check is driven by the type, not the values, so dropping trailing zeros (as in CAST(1.2300 AS decimal(5,2))) raises as well.

Addition, subtraction, modulo, and ROUND are exempt: they never reduce scale in a way NUMERIC_ROUNDABORT reports, so they round silently regardless of the setting.

When both ANSI_WARNINGS and ARITHABORT are OFF, a round-abort produces NULL instead of raising an error.

When SET NUMERIC_ROUNDABORT is OFF, the value is always rounded silently and no error or NULL is produced. The default is OFF.

Permissions#

Requires membership in the public role.

See Also#