CommencerCommencer gratuitement

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.

Cet exercice fait partie du cours

Functions for Manipulating Data in SQL Server

Afficher le cours

Exercice interactif pratique

Essayez cet exercice en complétant cet exemple de code.

SELECT 
	first_name,
	last_name,
	email,
	-- Replace "yahoo.com" with "live.com"
	___ AS new_email
FROM voters;
Modifier et exécuter le code