How do you turn off a specific bit in a bit mask?
t-sql
Solution
Found it! Use & ~ like this...
UPDATE MyTable SET
MyBitmask = MyBitmask & ~128 -- 8th bit
WHERE MyID = 123
The ~ operator flips all the bits (1s become 0s and 0s become 1s). Just set the value that you flip to the one you want to turn off and use & to safely turn off just the one specific bit without having to check to see if the bit is set.
Problem
In TSql, how do you turn off a specific bit in a bitmask without having to check to see if the bit is set or not?