SQL Server 2005 Bitwise Exclusive OR Operator

Hi

In SQL server 2005 if we want to perform a bitwise exclusive or operation between two integers then we can use the ^(Shift + 6) character. The exact syntax would be like

Expression ^ Expression

For example 3 ^ 2

The statement would return true since one of the expression evaluates true. Note this only works with expression integer category data types, bit, binary and varbinary data types.

The operator performs logical or , taking each corresponding for both expressions. The bits in the result are set to 1 if only one bits in the input expressions have value one. If both bits are either 0 or 1 the bit in the result will be cleared to the value of 0.

In case the two expressions have different integer data types (smallint, tinyint or int), the smaller data type argument is converted to the larger data type

Thanks
Vikram


Share this post   Email it |  digg it! |  reddit! |  bookmark it!

Feedback

Please post your comments:

Name:  
Email (optional): Your email address will not be posted.
URL (optional):
Comments: HTML will be ignored, URLs will be converted to hyperlinks  
Enter the text you see in the box:
 
Copyright © 2006 - 2008 Vikram Lakhotia