Skip to content
Advertisement

Convert negative data into positive data in SQL Server

The current data of the table is:

  a   b
---------
 -1   5
-11   2
 -5  32

My request is to convert every data into a positive value.

Unfortunately, I forgot the name of the built-in function of SQL Server that enables to convert.

Advertisement

Answer

You are thinking in the function ABS, that gives you the absolute value of numeric data.

SELECT ABS(a) AS AbsoluteA, ABS(b) AS AbsoluteB
FROM YourTable
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement