LEFT_SHIFT
bit-level operation
What changes
- Input
- integer or binary arguments
- Output or change
- computed value
- Return type
- Returns the same type as expression_value. The shift_amount parameter is cast to a bigint. The parameter can be positive or negative, and can also be greater than the number of bits in the data type o
Syntax at a glance
LEFT_SHIFT ( expression_value , shift_amount ) expression_value << shift_amount
Work example
Move a value left by a number of bits in a flag or encoding calculation.
Try zero, the lowest bit, the highest bit, and a negative value of the same SQL type.
Check your work Check input width and sign because shifted bits can leave the represented range.
Open Microsoft Learn for full syntax, permissions, and details for your version.