Bitwise Operators (Transact-SQL)

Bitwise Operators (Transact-SQL)

 

THIS TOPIC APPLIES TO: yesSQL Server (starting with 2008)yesAzure SQL DatabaseyesAzure SQL Data Warehouse yesParallel Data Warehouse

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

OperatorMeaning
& (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 operandRight operand
binaryint, smallint, or tinyint
bitint, smallint, tinyint, or bit
intint, smallint, tinyint, binary, or varbinary
smallintint, smallint, tinyint, binary, or varbinary
tinyintint, smallint, tinyint, binary, or varbinary
varbinaryint, smallint, or tinyint

Operators (Transact-SQL)
Data Types (Transact-SQL)

Community Additions

ADD
Show:
© 2016 Microsoft