The bitwise operators are a Transact-SQL extension for use with integer type data. These operators convert each integer operand into its binary representation, then evaluate the operands column by column. A value of 1 corresponds to true; a value of 0 corresponds to false.
Table 4-3 summarizes the results for operands of 0 and 1. If either operand is NULL, the bitwise operator returns NULL:
& ( and) |
1 |
0 |
1 |
1 |
0 |
0 |
0 |
0 |
| ( or) |
1 |
0 |
1 |
1 |
1 |
0 |
1 |
0 |
^ (exclusive or) |
1 |
0 |
1 |
0 |
1 |
0 |
1 |
0 |
~ (not) |
||
1 |
FALSE |
|
0 |
0 |
The examples in Table 4-4 use two tinyint arguments, A = 170 (10101010 in binary form) and B = 75 (01001011 in binary form).
Copyright © 2005. Sybase Inc. All rights reserved. |