Sql Server Sign Function

SQL Server: SIGN Function

In this post explains how to use the SIGN function in SQL Server (Transact-SQL) with syntax and examples.

Description

In SQL Server (Transact-SQL), the SIGN function returns a value indicating the sign of a number.

Syntax

The syntax for the SIGN function in SQL Server (Transact-SQL) is:

SIGN( number )

Parameters or Arguments

number

The number to test for its sign.

Note

  • If number 0, then sign returns -1.
  • If number = 0, then sign returns 0.
  • If number > 0, then sign returns 1.

Applies To

The SIGN 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 SIGN function examples and explore how to use the SIGN function in SQL Server (Transact-SQL).

For example:

SELECT SIGN(-23);
Output: -1

SELECT SIGN(-0.1);
Output: -1.0

SELECT SIGN(0);
Output: 0

SELECT SIGN(0.1);
Output: 1.0

SELECT SIGN(14);
Output: 1