How to remove or replace a string in your text field by using SQL Code

How Can We Help?

< Back

For Example removing the unwanted </br> tags from your presentation layer.

Syntax:

Replace (string to evaluate, substring to look for, what to replace it with)

So in the example:

REPLACE(Description, ‘<br />’, ”) as Description

This will look in the field called description and find all instances of ‘<br/> and replace them with an empty string and then name the field as it was originally.

REPLACE(‘BLAH_BLAH_BLAH<br/> BLAH_BLAH_BLAH<br/>BLAH_BLAH’, ‘<br />’, ”) as Description

This look at the text string provided and replaces the <br/> text with nothing and will result in the BLAH_BLAH_BLAHBLAH_BLAH_BLAHBLAH_BLAH’

While

REPLACE(‘BLAH_BLAH_BLAH<br/> BLAH_BLAH_BLAH<br/>BLAH_BLAH’, ‘<br />’, ‘ ‘) as Description

This look at the text string provided and replaces the <br/> text with one space and will result in the BLAH_BLAH_BLAH  BLAH_BLAH_BLAH  BLAH_BLAH

These can be nested so that the string in the replace command is the result of the string returned in another replace command.

REPLACE(REPLACE(Description, ‘<br />’, ”), ‘some other thing toreplace‘, ‘what you want to replace it with’) AS Description.

Comments are closed.

This is the legacy version of the XMPro Documentation site. For the latest XMPro documentation, please visit documentation.xmpro.com

X