Hello friends, in this article we will discuss about the function Translate of SQL Server 2017.

TRANSLATE() function is similar to REPLACE() function but using Translate in your query will helps you in avoiding using Replace() function multiple times.

Syntax –

TRANSLATE (input string, replaced characters, translations)


Let’s see an example -

SELECT TRANSLATE('2*[3+4]/{7-2}', '[]{}', '()()');

In this expression we want to replace the []{} brackets with ()() brackets.

So, using Translate function I just have to write a simple expression.

If we need to do the same task using Replace() function then we need to write the expression in this way –

SELECT REPLACE(REPLACE(REPLACE(REPLACE('2*[3+4]/{7-2}','[','('), ']', ')'), '{', '('), '}', ')');

So, we have seen that the output using both functions are same but translate is much simpler than replace function.

Here, is another example of Translate function –

SELECT TRANSLATE ('K@pilS!ingh','@!','ai')

One more point, while passing the parameters to Translate function, the second and third argument should contain equal characters else you will receive the following error -

That’s all for the day folks.

Have a happy learning J

See Also