bugl
bugl
HomeLearnPatternsSearch
HomeLearnPatternsSearch

Loading lesson path

Learn/SQL/SQL References
SQL•SQL References

SQL Server TRANSLATE() Function

Concept visual

SQL Server TRANSLATE() Function

Pointer walk
two pointers
leftright102132436485116
left=0
right=6
1
3

Start at both ends

Example

Return the string from the first argument AFTER the characters specified in the second argument are translated into the characters specified 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 the characters specified in the second argument are translated into the characters specified in the third argument.

Note:

The TRANSLATE() function will return an error if characters and translations have different lengths.

Syntax

Translate(

string, characters, translations )

Parameter Values

Parameter

Description string

Required. The input string characters Required. The characters that should be replaced translations Required. The new characters

Technical Details

Works in:

SQL Server (starting with 2017)

More Examples

Example

Return the string from the first argument AFTER the characters specified in the second argument are translated into the characters specified in the third argument:

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

Previous

❮ SQL Server Functions

Next

Previous

SQL Server SUBSTRING() Function

Next

SQL Server TRIM() Function