SALES: 1-800-867-1380
9 out of 13 rated this helpful - Rate this topic

# Operators (Windows Azure SQL Database)

Updated: February 17, 2014

This topic is OBSOLETE. You can find the most current version in the SQL 14 Transact-SQL Reference.

An operator is a symbol specifying an action that is performed on one or more expressions. The following table lists the operator categories that Windows Azure SQL Database supports.

Operator Category SQL Database Support

Yes

Yes

Yes

Yes

Yes

Yes

Other Miscellaneous Operators (String Concatenation Operator and Assignment Operator)

Yes

Scope Resolution Operator

No

Important
For more information about SQL grammar and operator usage and examples, see Operators (Transact-SQL) in SQL Server Books Online.

## Arithmetic Operators

Arithmetic operators perform mathematical operations on two expressions of one or more numeric data types. The following table lists the arithmetic operators that Windows Azure SQL Database supports:

Operator Meaning

- (Subtract)

Subtraction

* (Multiply)

Multiplication

/ (Divide)

Division

% (Modulo)

Returns the integer remainder of a division. For example, 12 % 5 = 2 because the remainder of 12 divided by 5 is 2.

## Compound Operators

Compound operators execute an operation and set an original value to the result of the operation. For example, if a variable @x equals 35, then @x += 2 takes the original value of @x, adds 2 and sets @x to that new value (37).

The following table lists the compound operators that Windows Azure SQL Database supports:

+=

Adds the specified amount to the original value and sets the original value to the result.

-=

-= (Subtract EQUALS)

Subtracts the specified amount from the original value and sets the original value to the result.

*=

*= (MULTIPLY EQUALS)

Multiplies by the specified value and sets the original value to the result.

/=

/= (DIVIDE EQUALS)

Divides by the specified value and sets the original value to the result.

%=

%= (Modulo EQUALS)

Divides by the specified value and sets the original value to the modulo.

&=

&= (Bitwise AND EQUALS)

Performs a bitwise AND operation and sets the original value to the result.

^=

^= (Bitwise Exclusive OR EQUALS)

Performs a bitwise exclusive OR operation and sets the original value to the result.

|=

|= (Bitwise OR EQUALS)

Performs a bitwise OR operation and sets the original value to the result.

## Bitwise Operators

Bitwise operators perform bit manipulations between two expressions of any of the data types of the integer data type category. The following table lists the bitwise operators that Windows Azure SQL Database supports:

Operator Meaning

& (Bitwise AND)

Bitwise AND (two operands).

| (Bitwise OR)

Bitwise OR (two operands).

^ (Bitwise Exclusive OR)

Bitwise exclusive OR (two operands).

## Logical Operators

Logical operators test for the truth of some condition. Logical operators, like comparison operators, return a Boolean data type with a value of TRUE, FALSE, or UNKNOWN. The following table lists the logical operators that Windows Azure SQL Database supports:

Operator Meaning

ALL

TRUE if all of a set of comparisons are TRUE.

AND

TRUE if both Boolean expressions are TRUE.

ANY

TRUE if any one of a set of comparisons is TRUE.

BETWEEN

TRUE if the operand is within a range.

EXISTS

TRUE if a sub query contains any rows.

IN

TRUE if the operand is equal to one of a list of expressions.

LIKE

TRUE if the operand matches a pattern.

NOT

Reverses the value of any other Boolean operator.

OR

TRUE if either Boolean expression is TRUE.

SOME

TRUE if some of a set of comparisons are TRUE.

## Comparison Operators

Comparison operators test whether two expressions are the same. The following table lists the comparison operators that Windows Azure SQL Database supports.

Operator Meaning

= (Equals)

Equal to

> (Greater Than)

Greater than

< (Less Than)

Less than

>= (Greater Than or Equal To)

Greater than or equal to

<= (Less Than or Equal To)

Less than or equal to

<> (Not Equal To)

Not equal to

!= (Not Equal To)

Not equal to (not ISO standard)

!< (Not Less Than)

Not less than (not ISO standard)

!> (Not Greater Than)

Not greater than (not ISO standard)

## Unary Operators

Unary operators perform an operation on only one expression of any one of the data types of the numeric data type category. The following table lists the unary operators that Windows Azure SQL Database supports.

Operator Meaning

+ (Positive)

The numeric value is positive.

- (Negative)

The numeric value is negative.

~ (Bitwise NOT)

Performs a bitwise logical NOT for the expression, taking each bit in turn. If expression has a value of 0, the bits in the result set are set to 1; otherwise, the bit in the result is cleared to a value of 0. In other words, ones are changed to zeros and zeros are changed to ones.

## Other Miscellaneous Operators

The following table lists the operators that do not fit into other categories and are supported by Windows Azure SQL Database.

Operator Meaning

+ (String Concatenation Operator)

The plus sign (+) is the operator that enables string concatenation.

= (Assignment Operator)

The equal sign (=) is the only Transact-SQL assignment operator.