Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

- (Negative)

SQL Server 2000

Is a unary operator that returns the negative value of a numeric expression.

Syntax
- numeric_expression
Arguments
numeric_expression
Is any valid expression in Microsoft® SQL Server™ 2000 Windows® CE Edition (SQL Server CE) of any of the data types of the numeric data type category, except the datetime data type.
Result Types

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

Examples

The following examples use the Northwind database to show how the positive and negative unary operators function. When a positive unary operator is set against a negative value, the returned value is negative (positive_value * negative_value = negative_value). When a negative unary operator is set against a negative value, the returned value is positive (negative_value * negative_value = positive_value).

SELECT -(DATEPART(day, OrderDate) - DATEPART(day, ShippedDate)) FROM Orders WHERE OrderID = '10248'
--With the negative unary operator, the value returned is '12'.

SELECT (DATEPART(day, OrderDate) - DATEPART(day, ShippedDate)) FROM Orders WHERE OrderID = '10248'
--Without a unary operator, the value returned is '-12'.

SELECT +(DATEPART(day, OrderDate) - DATEPART(day, ShippedDate)) FROM Orders WHERE OrderID = '10248'
--With the positive unary operator, the value returned is '-12'.

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.