Export (0) Print
Expand All


SQL Server 2000

Returns the positive (+1), zero (0), or negative (-1) sign of the given expression.

SIGN ( numeric_expression ) 
Is an expression of the exact numeric or approximate numeric data type categories, or types that are implicitly convertible to float (except for the bit data type).
Return Types

Returns the same type as numeric_expression except for the following expressions.

Specified expression Return type
tinyint, smallint int
real/float float
Nonnumeric types that can be implicitly converted to float float

The following example returns the SIGN of the difference between the units of products in stock and units of products that have been ordered in the Products table of the Northwind database.

SELECT (UnitsInStock - UnitsOnOrder), SIGN(UnitsInStock - UnitsOnOrder)
FROM Products

© 2014 Microsoft