Curriculum
Course: SQL
Login

Curriculum

SQL

SQL References

0/80

MySQL Functions

0/139

SQL Server Functions

0/84

SQL Quick Ref

0/1
Text lesson

TRANSLATE

Example

Return the string from the first argument after replacing each character specified in the second argument with the corresponding character in the third argument.

SELECT TRANSLATE(‘Monday’‘Monday’‘Sunday’); // Results in Sunday

Definition and Usage

The TRANSLATE() function returns the string from the first argument after replacing characters specified in the second argument with the corresponding characters in the third argument.

Note: An error will occur if the number of characters in the second and third arguments are not equal.

Syntax

TRANSLATE(string, characters, translations)

Parameter Values

Parameter

Description

string

Required. The string to be processed.

characters

Required. The characters to be replaced.

translations

Required. The replacement characters.

Technical Details

Works in:

 Available in SQL Server starting from version 2017.

More Examples

Example

Return the string from the first argument after replacing the characters specified in the second argument with those in the third argument.

SELECT TRANSLATE(‘3*[2+1]/{8-4}’‘[]{}’‘()()’); // Results in 3*(2+1)/(84)