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
 SQL Server Development (2000)
 Query

Author  Topic 

shubhada
Posting Yak Master

117 Posts

Posted - 2008-02-26 : 04:23:02
I have one table with column IsMarried and value for this column is 'Y' and 'N'.
but by mistake data entered in this column is wrong.
also this table have milion records. Considering performance .How I can swap the
value of IsMarried column.


current it is as follow

col1 colname IsMarried
1 abc Y
2 xyz N
3 pqr N
4 lmn y
.
.
.

but it should be as follow

col1 colname IsMarried
1 abc N
2 xyz Y
3 pqr Y
4 lmn N
.
.
.

SQLTeam

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-02-26 : 04:25:26
UPDATE Table
SET IsMarried=CASE WHEN IsMarried='Y' THEN 'N' ELSE 'Y' END
Go to Top of Page

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2008-02-26 : 04:26:02
[code]UPDATE TABLE
SET COL = CASE WHEN COL = 'Y' THEN 'N' ELSE 'Y' END
WHERE COL IN ('Y','N')[/code]

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page
   

- Advertisement -