0

I have a table in which I have 2 Column ID Int and IsActive Bit. I want to update bit value. If bit is true then false and if bit is flase then true.

For This I have used below query and its works fine but is there any other way to do this task.

Update  Table_1  set IsActive = Case when IsActive = 0 then 1 Else 0 End

Thanks, Hitesh Paghadal

Hitesh
  • 1,066
  • 4
  • 24
  • 46

1 Answers1

2

Duplicate of Boolean 'NOT' in T-SQL not working on 'bit' datatype? which gives the answer "col = ~ col" as the XOR operator - it also illustrates every other method of doing it.

Community
  • 1
  • 1
PhillipH
  • 5,938
  • 1
  • 13
  • 24