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.
| Author |
Topic |
|
chedderslam
Posting Yak Master
223 Posts |
Posted - 2009-07-02 : 11:36:10
|
| I have a column that might be one of several values, and each needs to be replaced with something different. So, how I do what I have below as a single statement?SELECT Replace(sessionID, 'ABC', ' 1') As idSELECT Replace(sessionID, 'DEF', ' 2') As idSELECT Replace(sessionID, 'GHI', ' 3') As idThanks. |
|
|
rohitkumar
Constraint Violating Yak Guru
472 Posts |
Posted - 2009-07-02 : 11:37:35
|
| SELECT Replace(Replace(sessionID, 'ABC', ' 1'), 'DEF', ' 2') and so on.... |
 |
|
|
vijayisonly
Master Smack Fu Yak Hacker
1836 Posts |
Posted - 2009-07-02 : 11:39:08
|
select sessionID = replace(replace(replace(sessionID,'ABC','1'),'DEF','2'),'GHI','3')quote: Originally posted by chedderslam I have a column that might be one of several values, and each needs to be replaced with something different. So, how I do what I have below as a single statement?SELECT Replace(sessionID, 'ABC', ' 1') As idSELECT Replace(sessionID, 'DEF', ' 2') As idSELECT Replace(sessionID, 'GHI', ' 3') As idThanks.
|
 |
|
|
chedderslam
Posting Yak Master
223 Posts |
Posted - 2009-07-02 : 11:50:43
|
| Perfect. Thanks guys. |
 |
|
|
|
|
|
|
|