ABS (TSQL Function)
Returns the absolute value of the argument.
Syntax
ABS ( numeric_expression )
Arguments
- numeric_expression
- is a numeric expression of type
int,bigint,money,numeric,float.
Return Types
Returns the same type as numeric_expression.
Remarks
For int and bigint argument types, ABS raises an overflow error if the argument is the minimum value for the type (see examples).
Examples
PRINT ABS(-3), ABS(0.00), ABS(-17e3), ABS(27);
The result is:
3| 0.00| 17000| 27|
This statement raises an error:
PRINT ABS(-2147483648);
The result is:
<Arithmetic error. INT overflow.>
because the valid range of int is [-2147483648, 2147483647].
The valid range for bigint is [-9223372036854775808, 9223372036854775807].