Sql Server Abs Function

SQL Server: ABS Function

In this post 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);
Output: 24

SELECT ABS(-24.6);
Output: 24.6

SELECT ABS(-24.65);
Output: 24.65

SELECT ABS(24.65 * -1);
Output: 24.65