Bitwise Exclusive OR (^)
The bitwise exclusive OR operator performs a bitwise logical exclusive OR operation between two operands.
The bitwise exclusive OR compares two bits and assigns a value equal to 0 to the result if the values of both the bits are either 0 or 1. Otherwise, this operator sets the corresponding result bit to 1. The exclusive OR operator can take only numeric values as its operands.
Syntax
expression ^ expression
Expression is any valid expression containing the integer data type, which is transformed into a binary number for the bitwise operation.
Values Returned
In a bitwise exclusive OR operation involving operands of different integer data types, the argument of the smaller data type is converted to the larger data type or to the data type that is immediately larger than the larger of the two operands. For example, when performing an exclusive OR operation involving smallint and integer, the smallint expression is converted to integer.
If any of the operands involved in a bitwise exclusive OR operation is signed, then the resultant value is also signed.
Examples
The following SQL query performs the exclusive OR on two numeric literals:
SELECT 12 ^ 8
The result is 4.
The binary representation of 12 (as a shortint) is 0000 0000 0000 0110 and that of 8 is 0000 0000 0000 0100. Performing the exclusive OR operation on these numbers yields the value 4:
0000 0000 0000 1100 ^ 0000 0000 0000 1000
= 0000 0000 0000 0100 (4)
============ 
*Note: The circumflex (^) cannot be used as part of a user-defined name.