Beginner

326. TRANSLATE Function

Learn how to replace individual characters within a string using a character mapping.

📘 Lesson 326 of 728 ⏱ 10 min 🎯 Intermediate

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.

SQL
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.

Have you finished this lesson?

Introduction to SQL – All Lessons