Follow these steps for exercises for bit manipulation functions in SQL Server 2022
- SQL Server 2022 Evaluation or Developer Edition
- VM or computer with 2 CPUs and at least 8Gb RAM.
- SQL Server Management Studio (SSMS). The latest 18.x build or 19.x build will work.
-
Execute the script getbits.sql to see how the BIT_COUNT() AND GET_BIT() functions work.
-
Execute the script packbits.sql to see how the RIGHT_SHIFT() and LEFT_SHIFT() and SET_BIT functions work.
Note in the scripts you will sometimes see the LEFT_SHIFT() AND << in back to back statements. The same for RIGHT_SHIFT() AND >>. This is just to demonstrate two ways of doing the same thing.