& (Bitwise AND)
operator & (Bitwise AND)
What changes
- Input
- operand expressions
- Output or change
- computed value
- Return type
- int if the input values are int. smallint if the input values are smallint. tinyint if the input values are tinyint or bit.
Syntax at a glance
expression & expression
Work example
A flag field needs & (Bitwise AND) to test or change a specific bit mask.
Use small integer values with one bit set at a time. Compare the mask before and after the expression.
Check your work & (Bitwise AND). The result of & (Bitwise AND) changes only the intended bit and keeps unrelated flags intact.
Open Microsoft Learn for full syntax, permissions, and details for your version.