
I guess you status column datatype is bit. if that is the case then you can use the XOR operator to toggle your bit flag like given below
--Update the values
UPDATE [SampleTable] SET [Status] = [Status] ^ 1
Change tablename as per your design.
Complete Code:
CREATE TABLE [dbo].[SampleTable](
[ID] [int] NULL,
[Name] [nchar](10) NULL,
[Status] [bit] NULL
);
--Insert some value in table
INSERT INTO [SampleTable]([ID],[Name],[Status])VALUES(1,'A','TRUE')
INSERT INTO [SampleTable]([ID],[Name],[Status])VALUES(2,'B','TRUE')
INSERT INTO [SampleTable]([ID],[Name],[Status])VALUES(3,'C','FALSE')
INSERT INTO [SampleTable]([ID],[Name],[Status])VALUES(4,'D','TRUE')
INSERT INTO [SampleTable]([ID],[Name],[Status])VALUES(5,'E','TRUE')
--Update the values
UPDATE [SampleTable] SET [Status] = [Status] ^ 1
Select * from SampleTable
You can see a working demo here :
http://sqlfiddle.com/#!3/db175/1 Thanks,
A2H
My Blog
Sriharim, if this helps please login to Mark As Answer. | Alert Moderator