# SQL ABS Function

The SQL Server ABS function is a Mathematical Function that will return the absolute positive value of the specified expression. The syntax of the ABS Function to find absolute value is:

```SELECT ABS (Numeric_Expression)
FROM [Source]```

## SQL ABS Function Example

The SQL Server ABS Function returns the absolute positive value of any numeric value. The following Mathematical Function query will show multiple ways to use the ABS function.

```DECLARE @i int
SET @i = -25.8

SELECT ABS(@i) AS [Absolute Value]

-- Calculating directly
SELECT ABS(-27) AS [Absolute Value]

-- Calculating directly
SELECT ABS(2 + 55 - 77) AS [Absolute Value]```

We used the ABS function to find the absolute value of the variable @i. It means ABS(-25.8) and assigned a new name, ‘Absolute Value’, using the ALIAS Column.

`SELECT ABS(@i) AS [Absolute Value]`

In the next Server statement, We used the absolute directly on the int value.

`SELECT ABS(-27) AS [Absolute Value]`

We used the ABS Function directly on the multiple values.

`SELECT ABS(2 + 55 - 77) AS [Absolute Value]`

It means ABS(2 + 55 – 77) => ABS (-20) = 20

## ABS Function Example 2

The SQL Server ABS Function also allows you to find the absolute values of column values. Here, we are going to find the absolute values for all the records present in [Service Grade] using this ABS Function.

For this ABS function demo, we use the Math Table data.

```SELECT [EnglishProductName]
,[Color]
,[StandardCost]
,[SalesAmount]