SQL Server SIGN() Function

SQL Server SIGN() function returns the sign of the specified expression. It is either positive (+1), negative (-1), or zero (0).



number: The positive or negative numeric value or expression.

Return Value

Returns the sign of the input value.

Note: If a number is less than zero, then SIGN () returns negative;

If a number is greater than zero, then SIGN () returns Positive;

If a number is equal to zero, then SIGN () returns zero.

The following example demonstrates the SIGN() function:

Example: SIGN()
SELECT SIGN (-234) AS SignNeg, SIGN (-0.45) AS DecNeg,  SIGN (0) AS SignZero,
SIGN (0.45) AS DecPos, SIGN (234) AS SignPos

The SIGN() function returns -1, 0, 1 based on the specified numeric value. It returns -1 for any negative number, -1.0 for negative decimal, 1.0 for positive decimal, 1 for positive integer, and 0 for 0 value.

Want to check how much you know SQL Server?