Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Using REPLACE Expand / Collapse
Author
Message
Posted Friday, December 6, 2013 6:27 AM


Say Hey Kid

Say Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey Kid

Group: General Forum Members
Last Login: 2 days ago @ 1:32 AM
Points: 666, Visits: 1,376
Hi

I have a requirement where I have replace two different strings with another string.
i.e. if there is 'Brigade Army or "Brigades Armies' in the result set, it should be replaced with 'BAY'.
How can I achieve it using REPLACE or any other way?
Post #1520554
Posted Friday, December 6, 2013 7:08 AM


SSC-Forever

SSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-Forever

Group: General Forum Members
Last Login: Today @ 3:11 PM
Points: 44,780, Visits: 42,685
Nested replace will do that.

REPLACE(REPLACE(SourceString,'Brigade Army','BAY'),'Brigades Armies','BAY')



Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass

Post #1520574
Posted Wednesday, December 11, 2013 2:19 AM


Say Hey Kid

Say Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey Kid

Group: General Forum Members
Last Login: 2 days ago @ 1:32 AM
Points: 666, Visits: 1,376
Thanks Gail, thanks for your reply. That has worked for me.
Post #1521778
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse