BIT_COUNT
bit-level operation
What changes
- Input
- integer or binary arguments
- Output or change
- computed value
- Return type
- bigint BIT_COUNT doesn't cast its input before counting bits. Because the binary representation of the same number depends on its data type, the result depends on the input type. For example, the foll
Syntax at a glance
BIT_COUNT ( expression_value )
Work example
Count set bits in a typed integer or binary value.
Try zero, the lowest bit, the highest bit, and a negative value of the same SQL type.
Check your work Use the same declared type for comparisons because representation depends on type.
Open Microsoft Learn for full syntax, permissions, and details for your version.