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)
String and, if it finds the
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!