Converting phone LETTERS into DIGITS in T-SQL / MS SQL Server

0
=
0
+
0
No specific Bitcoin Bounty has been announced by author. Still, anyone could send Bitcoin Tips to those who provide a good answer.
0

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!

enter image description here

1 Answer

1
=
0
=
$0
Internet users could send Bitcoin Tips to you if they like your answer!

Here is my solution:

  1. create dbo.Translate function by running a T-SQL script from this answer
  2. use the follwing code to process phone letters into their corresponding digits:

.

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

SEND BITCOIN TIPS
1

Too many commands? Learning new syntax?

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!

Post Answer