T-SQL 101: 52 Using TRANSLATE to make multiple string replacements in SQL Server
I previously mentioned that there were three functions for replacing values in strings. We saw REPLACE and STUFF. The other one is relatively new (SQL Server 2017) and it’s called TRANSLATE.
Here’s an example of how I can use it to change the format of a phone number:
The first parameter is the string to work on, the second parameter is a list of individual characters to replace, and the third parameter (which must be a string the same length as the second parameter), is the set of replacement characters.
2020-01-13