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:

  1. If number> 0, SIGN returns 1
  2. If number = 0, SIGN returns 0
  3. If number <0, SIGN returns -1

Syntax

To use the SIGN function in SQL Server, we use the following syntax:

 SIGN(number) 

Parameters :

  1. number: number passed to get the mark

Note :

  1. 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

May be interested

  • SUM function in SQL ServerPhoto of SUM function in SQL Server
    the sql server sum function returns the total value of a column, a data set, or an expression.
  • CURRENT_TIMESTAMP command in SQL ServerPhoto of CURRENT_TIMESTAMP command in SQL Server
    the 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 ServerPhoto of DATENAME function in SQL Server
    the 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 ServerPhoto of DATEDIFF function in SQL Server
    this 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 ServerPhoto of DATEADD function in SQL Server
    the dateadd function in sql server returns a new time value when it is added a specified time period.
  • DATEPART function in SQL ServerPhoto of DATEPART function in SQL Server
    the 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)