Click here to Skip to main content
15,892,797 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I have table with Auto increment Id ,With one Coulum having alternate values 0 and 1 in each field in coulumn Name Values,I need to replace each 0 by value 1 And each 1 by value 0 .....Can any one help me to doing it....!!!!!!!!!!
Posted
Comments
gregorio89 8-Jul-15 8:33am    
something like

id value
1 0
2 1
3 0
4 1




?

Try this
C#
UPDATE Table_Name
SET Column_Name = CASE Column_Name WHEN 0 THEN 1  WHEN 1 THEN 0 END

Regards..
 
Share this answer
 
SQL
UPDATE YourTable
SET YourTable.ColWith0or1 =  CASE WHEN YourTable.ColWith0or1 = 0 THEN 1 ELSE 0 END
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900