How to convert letters used in phone numbers into digits, i.e. input string '1-800-FLOWERS' should return '1-800-3569377', using a T-SQL? In Oracle, I would have used PL/SQL TRANSLATE function, however I need to do it in T-SQL and there is no similar function in T-SQL.
Please take a look at this image - this is the transformation I am looking for Thanks!
Here is my solution:
dbo.Translate
function by running a T-SQL script from this answer.
select dbo.Translate('1-800-FLOWERS', 'abcdefghijklmnopqrstuvwxyz', '22233344455566677778889999')
-------------------------
1-800-3569377
(1 row(s) affected)
You could also take a look here if you need to do phone letters translation in JavaScript
FavScripts.com is a free tool to save your favorite scripts and commands, then quickly find and copy-paste your commands with just few clicks.
Boost your productivity with FavScripts.com!