views:

548

answers:

3

I'm trying to perform a bitwise NOT in SQL Server. I'd like to do something like this:

update foo
set Sync = NOT @IsNew

Note: I started writing this and found out the answer to my own question before I finished. I still wanted to share with the community, since this piece of documentation was lacking on MSDN (until I added it to the Community Content there, too).

+1  A: 

Bitwise NOT: ~

Bitwise AND: &

Bitwise OR: |

Bitwise XOR: ^

More info: http://www.tar.hu/sqlbible/sqlbible0084.html

Even Mien
+4  A: 

Lacking on MSDN? http://msdn.microsoft.com/en-us/library/ms173468(SQL.90).aspx

Blorgbeard
D'oh. I just looked under bitwise operators and ~ unary operators :)
Even Mien
+2  A: 

Yes, the ~ operator will work.

update foo
set Sync = ~@IsNew
binarycoder