The TRANSLATE function replaces characters in a string according to a character-by-character mapping between a source set and a replacement set.
TRANSLATE can perform multiple character substitutions in a single operation and is useful for cleaning structured text.
Replace several unwanted punctuation characters with spaces.
SELECT
TRANSLATE(CustomerName, '-._', ' ') AS CleanName
FROM Customers;
TRANSLATE is useful in data cleansing, text normalization, identifier processing, and ETL transformations.
- TRANSLATE performs character mapping.
- Multiple characters can be replaced in one operation.
- It differs from REPLACE.
- It is useful for data cleansing.
- Syntax and behavior vary by database.
What is TRANSLATE used for?
TRANSLATE replaces individual characters according to a defined character mapping.
How is TRANSLATE different from REPLACE?
REPLACE substitutes a specified string, while TRANSLATE generally maps individual characters from one character set to another.