Follow by Email

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:


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


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 :)


Post a Comment


Design by Abhinav Ranjan Sinha