ABS

Transact-SQL Reference

Transact-SQL Reference

ABS

Returns the absolute, positive value of the given numeric expression.

Syntax

ABS ( numeric_expression )

Arguments

numeric_expression

Is an expression of the exact numeric or approximate numeric data type category, except for the bit data type.

Return Types

Returns the same type as numeric_expression.

Examples

This example shows the effect of the ABS function on three different numbers.

SELECT ABS(-1.0), ABS(0.0), ABS(1.0)

Here is the result set:

---- ---- ----
1.0  .0   1.0

The ABS function can produce an overflow error, for example:

SELECT ABS(convert(int, -2147483648))

Here is the error message:

Server: Msg 8115, Level 16, State 2
Arithmetic overflow error converting expression to type int.

See Also

CAST and CONVERT

Data Types

Mathematical Functions