SQL Server Documentation

TRANSLATE (Transact‑SQL)

Syntax

TRANSLATE ( string_expression , characters , translations )

string_expression – The input string to be translated. nvarchar, varchar, char, or nchar types are allowed.

characters – A string containing the characters to be replaced.

translations – A string containing the replacement characters. Each character in characters is replaced by the character at the same position in translations.

Parameters

ParameterTypeDescription
string_expressionnvarchar | varchar | char | ncharThe source string to translate.
charactersnvarchar | varchar | char | ncharCharacters to be replaced.
translationsnvarchar | varchar | char | ncharReplacement characters.

Return Type

Returns the same data type as string_expression with the translations applied. If string_expression is NULL, the result is NULL.

Remarks

Examples

Basic character replacement

SELECT TRANSLATE('SQL Server 2022', 'S2022', 'R1111') AS Result; -- Result: RQL Server 1111

Removing characters

SELECT TRANSLATE('Hello, World!', '!,', '') AS Cleaned; -- Cleaned: Hello World

Case conversion

SELECT TRANSLATE('MixedCASE', 'abcdefghijklmnopqrstuvwxyz', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ') AS Uppered; -- Uppered: MIXEDCASE

See Also