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 ?

Author  Topic 

melcraig
Starting Member

39 Posts

Posted - 2006-08-08 : 11:13:55
I am trying to convert data to a new db. I have one column where the data is either 'Y' or 'N'.

I need to change all the 'Y' to 'N'
and
change all the 'N' to 'Y'

I would like to do this in a sproc, I will be doing this nightly, but when I do my updates it changes them all to 'N'

Please help!
Mel

Srinika
Master Smack Fu Yak Hacker

1378 Posts

Posted - 2006-08-08 : 11:28:01
Either Use Temp table or
First Update Y to Z, N to Y then Z to N

Srinika
Go to Top of Page

melcraig
Starting Member

39 Posts

Posted - 2006-08-08 : 11:51:17
Thank You!
The update worked great.
I was confusing myself and changing everythin back to 'N'
Again Thanks
Mel
Go to Top of Page

Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)

7020 Posts

Posted - 2006-08-08 : 12:05:10
This should do it in one update stetement.

Update MyTable
set
MyCol = case MyCol
when 'Y' then 'N'
when 'N' then 'Y'
else MyCol
where
MyCol in ('Y','N')


CODO ERGO SUM
Go to Top of Page
   

- Advertisement -