tsql - How do you turn off a specific bit in a bit mask? -


in tsql, how turn off specific bit in bitmask without having check see if bit set or not?

found it! use & ~ this...

update mytable set         mybitmask = mybitmask & ~128 -- 8th bit     myid = 123 

the ~ operator flips bits (1s become 0s , 0s become 1s). set value flip 1 want turn off , use & safely turn off 1 specific bit without having check see if bit set.


Comments

Popular posts from this blog

javascript - Enclosure Memory Copies -

php - Replacing tags in braces, even nested tags, with regex -