SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Replace unknown string with new value
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

mr_evans2u
Starting Member

2 Posts

Posted - 01/16/2013 :  12:36:21  Show Profile  Reply with Quote
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 '---'

Edited by - mr_evans2u on 01/16/2013 12:38:36

djj55
Constraint Violating Yak Guru

USA
313 Posts

Posted - 01/16/2013 :  12:43:18  Show Profile  Reply with Quote
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 - 01/16/2013 :  12:46:04  Show Profile  Reply with Quote
djj55 that is perfect!!!
Thank you very much
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000