Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I flip a bit in SQL Server?

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).

like image 660
Even Mien Avatar asked Oct 04 '08 23:10

Even Mien


1 Answers

Yes, the ~ operator will work.

update foo set Sync = ~@IsNew 
like image 55
Jason Kresowaty Avatar answered Sep 19 '22 06:09

Jason Kresowaty