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 |
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.
TRANSLATE(string, characters, translations) |
Parameter |
Description |
string |
Required. The string to be processed. |
characters |
Required. The characters to be replaced. |
translations |
Required. The replacement characters. |
Works in: |
Available in SQL Server starting from version 2017. |
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)/(8–4) |