Answer:
--Create Table
CREATE TABLE EMPMaster(
[EMP_Name] [varchar](50) ,
Gender Char(1)
)
--Insert Record
Insert INTO EMPMaster Values('AA','M')
Insert INTO EMPMaster Values('BB','M')
Insert INTO EMPMaster Values('CC','F')
Insert INTO EMPMaster Values('DD','M')
Insert INTO EMPMaster Values('EE','F')
Insert INTO EMPMaster Values('FF','F')
--Update Query
Update EMPMaster SET Gender=Case When Gender='M' Then 'F'
Else 'M' END
Asked In: Many Interviews |
Alert Moderator