Dela via


Bitwise Operators (Transact-SQL)

Bitwise operators perform bit manipulations between two expressions of any of the data types of the integer data type category.

Operator

Meaning

& (Bitwise AND)

Bitwise AND (two operands).

| (Bitwise OR)

Bitwise OR (two operands).

^ (Bitwise Exclusive OR)

Bitwise exclusive OR (two operands).

The operands for bitwise operators can be any one of the data types of the integer or binary string data type categories (except for the image data type), except that both operands cannot be any one of the data types of the binary string data type category. The following table shows the supported operand data types.

Left operand

Right operand

binary

int, smallint, or tinyint

bit

int, smallint, tinyint, or bit

int

int, smallint, tinyint, binary, or varbinary

smallint

int, smallint, tinyint, binary, or varbinary

tinyint

int, smallint, tinyint, binary, or varbinary

varbinary

int, smallint, or tinyint