Sir, I need your help in the following topic.
I have a table named tbl_Person. It has columns: id(numeric(18,0), firstName(varchar(20), Gender(int).
please find the attached file with this for screenshot.
in that, I gave value 1 to Male and 2 to Female. Then all row with gender male show 1 and female with 2.
Now I want to change the Female corresponding number from 2 to 1 and male from 1 to 2.
Please give me the query to interchange the value of rows.
SQL Server Query to Interchage row value
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.


Jignesh TrivediRank #16 · 50.3K reputationPosted Oct 8, 2013, 1:43 AM EDT
Try following query
UPDATE tbl_Person
set Gender = CASE WHEN Gender = 1 THEN 2 ELSE 1 END
hope this will help you....
venkata kumarRank #5,034 · 314 reputationPosted Oct 8, 2013, 1:53 AM EDT
try what ever jignesh told