Jaa


- (Negative) (Transact-SQL)

Returns the negative of the value of a numeric expression (a unary operator).

Topic link iconTransact-SQL Syntax Conventions

Syntax

- numeric_expression

Arguments

  • numeric_expression
    Is any valid expression of any one of the data types of the numeric data type category, except the date and time category.

Result Types

Returns the data type of numeric_expression, except that an unsigned tinyint expression is promoted to a signed smallint result.

Examples

A. Setting a variable to a negative value

The following example sets a variable to a negative value.

USE tempdb;
GO
DECLARE @MyNumber decimal(10,2);
SET @MyNumber = -123.45;
SELECT @MyNumber;
GO

B. Changing a variable to a negative value

The following example changes a variable to a negative value.

USE tempdb;
GO
DECLARE @Num1 int;
SET @Num1 = 5;
SELECT -@Num1;
GO

See Also

Reference

Data Types (Transact-SQL)
Expressions (Transact-SQL)
Operators (Transact-SQL)

Help and Information

Getting SQL Server 2005 Assistance