Friday 30 August 2013

How to Change Gender Male to Female, Female To Male In Sql Server Database

Theres are  two option which i can help you with:

1.

You can do it using only one UPDATE query:

UPDATE emp SET gender =
CASE gender WHEN 'M' THEN 'F' WHEN 'F' THEN 'M' ELSE gender END

2.

Suppose the the table name is "Employees", gender column is "Gender" which keeps "M" for Male and "F" for female.

Then this SQL query should do the job:

UPDATE Employees, SET Gender='Z' WHERE Gender='F';
UPDATE Employees, SET Gender='F' WHERE Gender='M';
UPDATE Employees, SET Gender='M' WHERE Gender='Z';

Change the queries appropriately according to your needs.

Enjoy :)

4 comments:

WEB OPTIMIZATION and SMO said...

Thanks for sharing!!!

kamlesh yadav said...

thanks

Franky said...

how to update the Gender column from M and F to Male and Female .

Unknown said...

can you posibal male to female female to male and third gender to male

Post a Comment


                                                            
 
Design by Abhinav Ranjan Sinha