Sql Query
How to update the table vale from 0 to 1 & 1 to 0 without using where clause?
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend4days leftRegister
Satyapriya NayakRank #47 · 31.5K reputationPosted Aug 11, 2013, 3:22 AM EDT
Jignesh TrivediRank #16 · 50.3K reputationPosted Aug 11, 2013, 7:19 PM EDT
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.