Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Update Same Column with Different Values

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2005-08-01 : 14:52:30
Rahul writes "Hi Friends

I have table with 2 cols the data is as follows

Name Gender
A M
B F
C M
D M
D F

.....

In a single query I want to change the values of M to F and F to M

Please help
Thanks
Rahul"

nathans
Aged Yak Warrior

938 Posts

Posted - 2005-08-01 : 15:08:52
Homework?? Look up case in BOL...


declare @deez table ([name] char(1), gender char(1))
insert into @deez
select 'A','M' union all
select 'B','F' union all
select 'C','M' union all
select 'D','M' union all
select 'E','F'

select * from @deez

update @deez
set gender = case gender
when 'M' then 'F'
else 'M'
end

select * from @deez


Nathan Skerl
Go to Top of Page
   

- Advertisement -