Transact-SQL Reference
- (Negative)
Is a unary operator that returns the negative value of a numeric expression (a unary operator).
Syntax
- numeric_expression
Arguments
numeric_expression
Is any valid Microsoft® SQL Server™ expression of any of the data types of the numeric data type category except the datetime or smalldatetime data types.
Result Types
Returns the data type of numeric_expression, except that an unsigned tinyint expression is promoted to a signed smallint result.
Examples
A. Set a variable to a negative value
This example sets a variable to a negative value.
DECLARE @MyNumber decimal(10,2)
@MyNumber = -123.45
B. Negate a value
This example negates a variable.
DECLARE @Num1 int
SET @Num1 = 5
SELECT -@Num1