Skip to content
Advertisement

SQL replace a string starting with a specific character

I have a column with text/sentences that may include strings starting with ‘@’. I need to remove all strings starting with ‘@’ from the texts. For example:

enter image description here

Is there any function that can do the trick? I have tried the following but this removes only the ‘@’ from the string:

Advertisement

Answer

One way to do it is with a recursive CTE:

See the demo.
Results:

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement