SQL Server: ABS Function
This SQL Server tutorial explains how to use the ABS function in SQL Server (Transact-SQL) with syntax and examples.
Description
In SQL Server (Transact-SQL), the ABS function returns the absolute value of a number.
Syntax
The syntax for the ABS function in SQL Server (Transact-SQL) is:
ABS( number )
Parameters or Arguments
- number
- The number to convert to an absolute value.
Applies To
The ABS function can be used in the following versions of SQL Server (Transact-SQL):
- SQL Server 2017, SQL Server 2016, SQL Server 2014, SQL Server 2012, SQL Server 2008 R2, SQL Server 2008, SQL Server 2005
Example
Let’s look at some SQL Server ABS function examples and explore how to use the ABS function in SQL Server (Transact-SQL).
For example:
SELECT ABS(-24); Result: 24 SELECT ABS(-24.6); Result: 24.6 SELECT ABS(-24.65); Result: 24.65 SELECT ABS(24.65 * -1); Result: 24.65