SET_BIT
bit-level operation
What changes
- Input
- integer or binary arguments
- Output or change
- computed value
- Return type
- The same type as expression_value. The bit_offset parameter is used to identify the nth bit of the data to set. In integer types, the 0th bit is the least significant bit. In binary types, the 0th bit
Syntax at a glance
SET_BIT ( expression_value , bit_offset ) SET_BIT ( expression_value , bit_offset , bit_value )
Work example
Set or clear one selected zero-based bit in a value.
Try zero, the lowest bit, the highest bit, and a negative value of the same SQL type.
Check your work Verify offset and requested bit value and test the least significant bit first.
Open Microsoft Learn for full syntax, permissions, and details for your version.