1. Learn
  2. /
  3. Courses
  4. /
  5. Functions for Manipulating Data in SQL Server

Exercise

Replacing parts of a string

Sometimes, you need to replace characters from a string with something else.

For example, if a name was inserted in a table with an extra character, you may want to fix the mistake.

If a company was acquired and changed its name, you need to replace the old company name with the new name in all documents stored in the database.

In this exercise, you will use a built-in function that replaces a part of a string with something else. For using the function correctly, you need to supply the following parameters:

  • the expression
  • the string to be found
  • the replacement string.

Instructions 1/3

undefined XP
  • 1

    Add a new column in the query in which you replace the "yahoo.com" in all email addresses with "live.com".

  • 2

    Replace the character "&" from the company name with "and".

  • 3

    Remove the string "(Valrhona)" from the company name "La Maison du Chocolat (Valrhona)".