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 06, 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: Wednesday, April 16, 2014 12:52 AM
Points: 588, Visits: 1,004
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 06, 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 @ 11:52 AM
Points: 41,530, Visits: 34,446
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: Wednesday, April 16, 2014 12:52 AM
Points: 588, Visits: 1,004
Thanks Gail, thanks for your reply. That has worked for me.
Post #1521778
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse