The REPLACE function searches a string for a specified sequence of characters and replaces matching occurrences with another sequence.
Imported data often contains inconsistent separators, abbreviations, or unwanted characters. REPLACE can standardize those values.
Replace hyphens in phone numbers with spaces.
SELECT
PhoneNumber,
REPLACE(PhoneNumber, '-', '') AS CleanPhoneNumber
FROM Customers;
REPLACE is useful in data cleaning, address standardization, identifier transformation, and text preparation.
- REPLACE substitutes text within a string.
- It can replace multiple occurrences.
- It is useful for data cleaning.
- It can standardize text formats.
- Replacement behavior depends on database settings.
What does REPLACE do?
REPLACE searches for specified text and substitutes it with another text value.
How can REPLACE help clean phone numbers?
It can remove unwanted characters such as hyphens, spaces, or brackets from phone numbers.