IniziaInizia gratis

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.

Questo esercizio fa parte del corso

Functions for Manipulating Data in SQL Server

Visualizza il corso

Esercizio pratico interattivo

Prova a risolvere questo esercizio completando il codice di esempio.

SELECT 
	first_name,
	last_name,
	email,
	-- Replace "yahoo.com" with "live.com"
	___ AS new_email
FROM voters;
Modifica ed esegui il codice