Returns the absolute, positive value of the given numeric expression.
ABS(numeric_expression)
Returns the same type as numeric_expression.
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.
CAST and CONVERT | Mathematical Functions |
Data Types |