I have a flags column in sql which is int.
I need to set a bit in a flag using an SQL statement. The corresponding C ++ operator looks something like this flags &= ~(unsigned long) (0x10000000).
I tried to do
update [Databases]
set flags = flags & ~0x10000000
but i get
Operand data type varbinary is invalid for '~' operator.
Then I tried to see that the convert function would be yild
select flagInt = CONVERT(int , 0x10000000)
gives me 268435456.
select flagIntInvert = ~CONVERT(int , 0x10000000)
gives me -268435457
which matches the signed int
flag 268435456 int
~flag -268435457 int
However i need unsigned versions
(uint32)flag 268435456 unsigned long
~(uint32)flag 4026531839 unsigned long
Is there a way to set the flag as inversion 0x10000000 ?
Thank.
source
share