bit-fields

How to read/write full 32 or 64 bits of an int or bigint bitmasked field in TSQL.

Setting the 32nd and 64th bits is tricky. 32-bit Solution: I got it to work for 32-bit fields. The trick is to cast the return value of the POWER function to binary(4) before casting it to int. If you try to cast directly to int, without first casting to binary(4), you will get an arithmetic overflow exception when operating on the 3...