Math Functions – SIGN()

I am going to press on with my series of short articles or tidbits on Transaction SQL math functions. Most, if not all, of these functions have been in the product before the release of SQL Server 2005.

I am very proud of my daughter making the advance math class in sixth grade. I am dedicating these blogs to her hard class work and love of the subject.

I will be exploring the SIGN() function today. This function takes as input a expression in either exact numeric or approximate numeric form. This does not include the BIT data type. It returns the positive (+1), zero (0), or negative (-1) sign of the specified expression.

The example below tests the SIGN() function with four different inputs: negative number, positive number, a zero value and a null value.

The output from the test is listed below.

In short, the SIGN function is an odd algorithm that returns one of three values given a non null number.

Related posts

Leave a Comment