SQL 如何查找某个位是否打开

SQL how to find if a certain bit is on

Select '5th bit on'
Where 16 & (2^(5-1)) > 0

为什么这行不通? 我只是想看看从十进制到二进制的某个位是否是on/off。 我一定是遗漏了一些非常基本的东西。

^xor operator, not the "power of" operator I suspect you expect it to be. Instead, you can use the power 函数:

Select '5th bit on'
Where 16 & (POWER(2, (5-1))) > 0