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 2008 Forums
 Transact-SQL (2008)
 Replace unknown string with new value

Author  Topic 

mr_evans2u
Starting Member

2 Posts

Posted - 2013-01-16 : 12:36:21
I want to replace an unknown string from HomeMDB with "YES" in my select statement.
Since I don't know what the value is or the exact length how do I replace the string with my own value?


SELECT TOP(250)Data.id, Data.HomeMDB
From Data
Where id = '%'

So lets say this query came back as:
id HomeMDB
11 CN=FLDPHIK09-12,ou=something,etc,etc,etc,etc
12 NULL


How can I get it to look like:
id HomeMDB
11 YES
12 ---

I know how to change the NULL value to '---'

djj55
Constraint Violating Yak Guru

352 Posts

Posted - 2013-01-16 : 12:43:18
How about something like:
SELECT TOP(250)Data.id, CASE WHEN Data.HomeMDB IS NULL THEN '---' ELSE 'YES' END AS HomeMDB
From Data
Where id = '%'



djj
Go to Top of Page

mr_evans2u
Starting Member

2 Posts

Posted - 2013-01-16 : 12:46:04
djj55 that is perfect!!!
Thank you very much
Go to Top of Page
   

- Advertisement -