Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
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


Mr or Mrs. 500

Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500

Group: General Forum Members
Last Login: Tuesday, July 22, 2014 6:03 AM
Points: 588, Visits: 1,061
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:14 AM
Points: 42,460, Visits: 35,520
Nested replace will do that.

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



Gail Shaw
Microsoft Certified Master: SQL Server 2008, MVP
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


Mr or Mrs. 500

Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500

Group: General Forum Members
Last Login: Tuesday, July 22, 2014 6:03 AM
Points: 588, Visits: 1,061
Thanks Gail, thanks for your reply. That has worked for me.
Post #1521778
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse