Sql Query
How to update the table vale from 0 to 1 & 1 to 0 without using where clause?
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Satyapriya NayakPosted Aug 11, 2013, 7:22 AM
Jignesh TrivediPosted Aug 11, 2013, 11:19 PM
hi,
In this case you can also use Exclusive OR bitwise operator.
try
create table #temp
(
Id int,
IsUpdated bit
)
Insert into #temp values(1,0)
Insert into #temp values(2,0)
Insert into #temp values(3,1)
Insert into #temp values(4,1)
select Id,IsUpdated,IsUpdated^1 from #temp
update #temp
set IsUpdated = IsUpdated^1
hope this will help you.