SIGN functions in SQL Server
This article will show you in detail how to use SIGN () function to handle SQL Server with syntax and specific examples to make it easier to visualize and capture functions.
Describe
The SIGN function in SQL Server is used to retrieve the sign of a number or the transmitted expression.
The function will return one of the following:
- If number> 0, SIGN returns 1
- If number = 0, SIGN returns 0
- If number <0, SIGN returns -1
Syntax
To use the SIGN function in SQL Server, we use the following syntax:
SIGN(number)
Parameters :
- number: number passed to get the mark
Note :
- SIGN function can be used in later versions of SQL Server: SQL Server 2017, SQL Server 2016, SQL Server 2014, SQL Server 2012, SQL Server 2008 R2, SQL Server 2008, and SQL Server 2005.
For example
See and explore some examples of SIGN functions in SQL Server.
SELECT SIGN(-23);
Result: -1
SELECT SIGN(-0.1);
Result: -1
SELECT SIGN(0);
Result: 0
SELECT SIGN(0.1);
Result: 1
SELECT SIGN(14);
Result: 1
SELECT SIGN(2019-2014);
Result: 1
Previous article: ROUND function in SQL Server
Next article: SUM function in SQL Server
4 ★ | 1 Vote
You should read it
May be interested
- SUM function in SQL Serverthe sql server sum function returns the total value of a column, a data set, or an expression.
- CURRENT_TIMESTAMP command in SQL Serverthe sql server current_timestamp function returns the current date and time, in the format 'yyyy-mm-dd hh: mi: ss.mmm'.
- DATENAME function in SQL Serverthe datename function in sql server returns a time value of the input argument, which can be day, month, year, quarter, hour, minute, second, millisecond ... the return value is a string type (ascii)
- DATEDIFF function in SQL Serverthis article will show you in detail how to use sql server's datetime datediff () function with syntax and specific examples to make it easier to visualize and capture functions.
- DATEADD function in SQL Serverthe dateadd function in sql server returns a new time value when it is added a specified time period.
- DATEPART function in SQL Serverthe datepart function in sql server returns a time value of the input argument, which can be day, month, year, quarter, hour, minute, second, millisecond ... the return value is an integer type (int)