How To Update Male TO Female and Female To Male [Resolved]

Posted by Nksingh420 under Sql Server on 4/8/2013 | Points: 10 | Views : 15451 | Status : [Member] | Replies : 4
I Have One Table Employee , in which table a column name Gender , it contain Male & Female only
I want to update my table with Male To Female and Female To Male in a Single Query ????




Responses

Posted by: Satyapriyanayak on: 4/9/2013 [Member] [MVP] Silver | Points: 50

Up
0
Down

Resolved
UPDATE table SET gender =
CASE gender WHEN 'male' THEN 'female' WHEN 'female' THEN 'male' ELSE gender END


If this post helps you mark it as answer
Thanks

If this post helps you mark it as answer
Thanks

Nksingh420, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Jayakumars on: 4/8/2013 [Member] [MVP] Bronze | Points: 25

Up
0
Down
hi
NkSignh Try this Working Good


Update Table2 set Gender='Male1' where Gender='FeMale'
Select * from dbo.Table2
Update Table2 set Gender='FeMale' where Gender='Male'
Select * from dbo.Table2
Update Table2 set Gender='Male' where Gender='Male1'
Select * from dbo.Table2

Mark as Answer if its helpful to you

Nksingh420, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Satyapriyanayak on: 4/9/2013 [Member] [MVP] Silver | Points: 25

Up
0
Down
UPDATE table SET gender =
CASE gender WHEN 'male' THEN 'female' WHEN 'female' THEN 'male' ELSE gender END

If this post helps you mark it as answer
Thanks

Nksingh420, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Jasminej on: 4/9/2013 [Member] Starter | Points: 25

Up
0
Down
UPDATE Employee SET Gender = CASE Gender WHEN 'Male' THEN 'Female' ELSE 'Male' END

GO


Nksingh420, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response