0

Is there any other way to replace multiple strings in sql server 2008r2? which is also fast?

My query is below.

Select REPLACE(REPLACE(EmailText,'#{Name}#',UV.Name),'#{organisation}#',CV.Organisation)

I am written it with example also

Select REPLACE(REPLACE('Hi #{Name}# from #{organisation}#','#{Name}#','Jhon'),'#{organisation}#','Cocacola')
1
  • Other than using a clr function, sql server does not support regular expressions. Replace is probably the best way to do it. Commented Aug 17, 2017 at 6:42

1 Answer 1

2

There are all sorts of ways:

But 'best' as in 'fastest' is probably going to be using REPLACE Repeatedly, as all the attempts in these links have some limitation..

Sign up to request clarification or add additional context in comments.

2 Comments

are you sure Replace is fast? I means if i will replace 5 to 6 strings, it wouldn't slow down the select statement?
Depends what you mean by fast. Sqlserver can replace your strings faster than I can replace strings with a pencil and paper?! Of course any additional processing of data will reduce the rate at which results can be produced, but your question doesn't really make sense because you're asking for absolute when this operation is relative. If you have a million replacements to make, you have to make them somehow, and it's going to take some time. So go make them with replace, and if it's too slow, try something else from these links. I think you'll come back to using replace in the end though

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.