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 - total earned - 0 BTC ($0 USD)

1
=
0
=
$0
Everyone, even non-registered users could send Bitcoin Tips to YOU if they are inspired by 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

Post Answer


Will Bitcoin Tipping become a new Internet Culture?


Please share our story! THANK YOU!