Click to Rate and Give Feedback
MSDN
MSDN Library
SQL Server
 + (Positive) (SQL Server Compact)
Collapse All/Expand All Collapse All
Other versions are also available for the following:
+ (Positive) (SQL Server Compact)

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

+ numeric_expression
numeric_expression

Any valid expression in SQL Server Compact 4.0 of any one of the data types in the numeric data type category, except the datetime data type.

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

The following examples use the Orders table 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, Order Date) - DATEPART(day, Shipped Date)) 
FROM Orders 
WHERE OrderID = '10248'
-- Without a unary operator, the value returned is '-12'.

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

SELECT -(DATEPART(day, Order Date) - DATEPART(day, Shipped Date)) 
FROM Orders 
WHERE OrderID = '10248'
-- With the negative unary operator, the value returned is '12'.
© 2012 Microsoft. All rights reserved. Terms of Use | Trademarks | Privacy Statement
Page view tracker