sign

Description

Returns the sign (+1 for positive, 0, or -1 for negative) of the specified value.

Syntax

sign(numeric)

Parameters

numeric

is any exact numeric (numeric, dec, decimal, tinyint, smallint, or int), approximate numeric (float, real, or double precision), or money column, variable, constant expression, or a combination of these.

Examples

Example 1

select sign(-123)
----------- 
        -1

Example 2

select sign(0)
----------- 
         0

Example 3

select sign(123)
----------- 
         1

Usage

Standards

ANSI SQL – Compliance level: Transact-SQL extension.

Permissions

Any user can execute sign.

See also

Functions abs, ceiling, floor, round