Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Simple text functions
How to modify Strings
22. The REPLACE() function


Great! You can also replace certain parts of a string with anything you want using the REPLACE() function. It works like this:

REPLACE(String, SubstringToChange, NewSubstring) 

This searches String and, if it finds the SubstringToChange, replaces SubstringToChange with the text in NewSubstring. Let's try it!

SELECT REPLACE(N'young man', N'young', N'old');

In the above example, the function will look for N'young' in the string N'young man' and will replace it with N'old'. As a result, we'll get N'old man'. Of course, you can provide a column name instead of an actual text.

Let's practice using this function in the exercise!


For the slogan with an Id = 1, replace the word 'Feel' with 'Touch'. Show the slogan's original text and the UpdatedText.

Stuck? Here's a hint!

Use REPLACE(Text, N'Feel', N'Touch'). Don't forget to rename the column with REPLACE() to UpdatedText.