Export (0) Print
Expand All

& (Bitwise AND)

SQL Server 2000

Performs a bitwise logical AND operation between two integer values.

Syntax
expression & expression
Arguments
expression
Is any valid expression in Microsoft® SQL Server™ 2000 Windows® CE Edition (SQL Server CE) of any of the data types of the integer data type category. expression is an integer parameter that is treated and transformed into a binary number for the bitwise operation.
Result Types

Returns an int if the input values are int, a smallint if the input values are smallint, or a tinyint if the input values are tinyint.

Examples

The following example performs the bitwise AND operation between two integer columns.

CREATE TABLE bitwise (a_int_value int NOT NULL, b_int_value int NOT NULL)
INSERT bitwise VALUES (170, 75)
SELECT a_int_value & b_int_value FROM bitwise
--Returns 10.

The binary representation of 170 (a_int_value or A, below) is 0000 0000 1010 1010. The binary representation of 75 (b_int_value or B, below) is 0000 0000 0100 1011. Performing the bitwise AND operation on these two values produces the binary result 0000 0000 0000 1010, which is decimal 10.

(A & B)
         0000 0000 1010 1010
         0000 0000 0100 1011
         -------------------
         0000 0000 0000 1010

Show:
© 2014 Microsoft