This SQL Server tutorial explains how to use the SIGN function in SQL Server (Transact-SQL) with syntax and examples.
Description
In SQL Server (Transact-SQL), the SIGN functions returns a value indicating the sign of a number.
Syntax
The syntax for the SIGN function in SQL Servers (Transact-SQL) is:
SIGN( number )
Parameters or Arguments
numberThe 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 Servers (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 functions examples and explore how to use the SIGN function in SQL Servers (Transact-SQL).
For example:
SELECT SIGN(-23); Result: -1 SELECT SIGN(-0.1); Result: -1.0 SELECT SIGN(0); Result: 0 SELECT SIGN(0.1); Result: 1.0 SELECT SIGN(14); Result: 1