How to format unformated phone numbers Please...,

Hello Good Evening, i have a phone number table which has single column in it with different style of phone numbers, i am trying to change it as required format
Required format are
1) Always start with a 1
2) Only Left 14 charcaters after spaces elimination (if there is any)
3) No spaces
4) special characters like (,),-,/ need to replace with '.'
5) if there is no separation/space then format 1.800.###.#### need to apply
create table #myphoneno (phone varchar(20))
Insert into #myphoneno values  ('(866) 987-3847' ) --- Rule 1,3,4
Insert into #myphoneno values  ('1-800-222-SAVE(7283)') --- Rule 2,4
Insert into #myphoneno values  ('(800) 111-4015') --Rule 3,4
Insert into #myphoneno values  ('18002288775')  ---Rule 5
Insert into #myphoneno values  ('(800) 2223415')--- Rule 1,3,4,5
Insert into #myphoneno values  ('(800) 2-MOHAN')--- Rule 1,,3,4
Insert into #myphoneno values  ('1-800-228-4995') ---Rule 4
Insert into #myphoneno values  ('877-233-0112')---- Rule 1,4
Insert into #myphoneno values  ('800 228 3315')--- 1,3,4
Insert into #myphoneno values  ('18002284225')---Rule 5
Insert into #myphoneno values  ('800/219-1140') --- Rule 1,4
Insert into #myphoneno values  ('1 (855) ECO-8107') -- Rule 3,4
Insert into #myphoneno values  ('(888) BOM4BQC')-- Rule1,3,4
Insert into #myphoneno values  ('877-421K-MOX')-- Rule 1,4
Select * from #myphoneno
---- Expected results as below
create table #myphonenoExpected (phone varchar(20))
Insert into #myphonenoExpected values  ('1.866.987.3847' )
Insert into #myphonenoExpected values  ('1.800.222.SAVE')
Insert into #myphonenoExpected values  ('1.800.111.4015')
Insert into #myphonenoExpected values  ('1.800.228.8775')
Insert into #myphonenoExpected values  ('1.800.222.3415')
Insert into #myphonenoExpected values  ('1.800.2.MOHAN')
Insert into #myphonenoExpected values  ('1.800.228.4995')
Insert into #myphonenoExpected values  ('1.877.233.0112')
Insert into #myphonenoExpected values  ('1.800.228.3315')
Insert into #myphonenoExpected values  ('1.800.228.4225')
Insert into #myphonenoExpected values  ('1.800.219.1140')
Insert into #myphonenoExpected values  ('1.855.ECO.8107')
Insert into #myphonenoExpected values  ('1.888.BOM.4BQC')
Insert into #myphonenoExpected values  ('1.877.421K.MOX')
Select * from #myphonenoExpected
Thank you in advance
Asiti

USE [Northwind]
create table #myphoneno (phone varchar(20))
Insert into #myphoneno values ('(866) 987-3847' ) --- Rule 1,3,4
Insert into #myphoneno values ('1-800-222-SAVE(7283)') --- Rule 2,4
Insert into #myphoneno values ('(800) 111-4015') --Rule 3,4
Insert into #myphoneno values ('18002288775') ---Rule 5
Insert into #myphoneno values ('(800) 2223415')--- Rule 1,3,4,5
Insert into #myphoneno values ('(800) 2-MOHAN')--- Rule 1,,3,4
Insert into #myphoneno values ('1-800-228-4995') ---Rule 4
Insert into #myphoneno values ('877-233-0112')---- Rule 1,4
Insert into #myphoneno values ('800 228 3315')--- 1,3,4
Insert into #myphoneno values ('18002284225')---Rule 5
Insert into #myphoneno values ('800/219-1140') --- Rule 1,4
Insert into #myphoneno values ('1 (855) ECO-8107') -- Rule 3,4
Insert into #myphoneno values ('(888) BOM4BQC')-- Rule1,3,4
Insert into #myphoneno values ('877-421K-MOX')-- Rule 1,4
;with mycte as(
Select phone,
replace(replace(replace(replace(replace( replace(phone,'(','.'),')','.'),'-','.'),'/','.'),' ','.'),'..','.') tmpCol
from #myphoneno)
,mycte1 as (select phone, case when left(tmpCol,1)='1' then tmpCol else '1.'+tmpCol end tmpcol1 from mycte)
select phone, Case when charindex('.', tmpcol1) >0 then left(replace(tmpcol1,'..','.') ,14) Else
substring (tmpcol1,1,1)+'.'+ substring (tmpcol1,2,3)+'.'
+ substring(tmpcol1,5,3)+'.' +substring (tmpcol1,8,4) end as newPhone from mycte1
drop table #myphoneno

Similar Messages

  • HT1349 just got a new iphone. How do you transfer phone numbers from an old iphone to a new one

    How do you transfer phone numbers from a 3gs to a 4s?

    PLug your 3gs into iTunes, in the left panel right click on your iPhone and create a backup. After the back up is complete plug your 4s into iTunes, right click on it in the left panel and select restore from backup, select the backup file from your 3gs and that should load everything from your 3gs to your new iphone
    http://support.apple.com/kb/HT2109

  • Standardizing the format of phone numbers in contacts

    I am looking for a script or app that will quickly standardize the format of phone numbers in my contacts.  Any suggestions?

    Before you sync your iPhone the next time, activate the option "sync addressbook" and "replace all Contacts on iPhone". The next sync will replace your contact info on your phone. From that point on all contact infos will be the same on your mac and and your phone. And changes or new infos will also be seen on both systems.
    Hope this helps

  • HT201328 How can I retrieve phone numbers in my contacts on my Iphone 4S?  Only email addresses are showing up.

    How can I retrieve phone numbers in my contacts? Only email addresses are showing.  This is on my Iphone 4S.  Thanks!

    Phone numbers are on phone only. I haven't been using iCloud to sync with iPad & Mac yet. This morning I started to text & my yahoo acct popped up &'asked for my password. When I entered it, that's when all info disappeared except for email addresses.

  • We have 2 iphones both synched to 1 ipad how do we reovw phone numbers from only one of the phones

    We have 2 iphones and they are both synched to an ipad, how do we reomve phone numbers from only one of the phones without hte numbers being removed from the other phone

    one can't sync iPhones with ipads
    best you can do is to sync all with iclouds
    if you do so and wish to stop syncing contacts with one of the iPhones you have set it not to sync contacts in the settings of the iPhone

  • I have an IPhone 5 and OS7 but I cannot block phone numbers.  there is no blue "i" next to my recently called numbers.  How can I block phone numbers?

    HELP!!! I have an IPhone 5 and OS7 but I cannot block phone numbers.  there is no blue "i" next to my recently called numbers.  How can I block phone numbers?

    Try restarting the phone to see if the blue i will appear afterwards. http://support.apple.com/kb/HT1430

  • How to change format of phone numbers in PowerShell?

    We need to append the area code and hyphen in front of the office phone number field in their domain user account for all our users that have office phones now that we are changing from 7 digit numbers to 10 digit numbers.
    I found a script that finds and edits phone numbers, but the author chose a different way to format the numbers.
    This is the part of the script I need to change:
    # Format number as xxx xx xx xxx.
            $Phone = '{0}
    {1} {2} {3}' -f$Phone.Substring(0,3),$Phone.Substring(3,2),$Phone.Substring(5,2),$Phone.Substring(7,3)
    I'm trying to figure out how to edit that so that it formats it as xxx-xxx-xxxx
    (3 digit area code, hyphen, 3 digit prefix, hyphen, four digit number) instead of xxx xx xx xxx.
    Can someone show how to rewrite this section?

    The modified script:
    # This format number as xxx-xxx-xxxx.
    $Phone = '{0}-{1}-{2}' -f $Phone.Substring(0,3),$Phone.Substring(3,3),$Phone.Substring(6,4)
    Hope this helps.
    Regards,
    thennet
    Please take a moment to "Vote as Helpful" and/or "Mark as Answer", where applicable. This helps the community, keeps the forums tidy, and recognises useful contributions. Thank you!

  • E72 - How to format the phone number on contact

    I can't figure out a easy for formatting my contact number to be like (xxx) xxx-xxxx or xxx-xxx-xxxx on e72 instead going to outlook make the changes and re-sync again. I find xxxxxxxxxx hard to read. I thought I found out how to add hypen "ctrl+(" but that basically long dash rather than short dash which you get an error if you try to send message with the phone number having the long dash. It is fine when you call. It is smart enough to strip out non-numerical value. But it is sms is not smart enough to remove it.

    ozidug wrote:
    The sad thing is that there is an international standard for phone numbers (+xxx) xxx-xxxx which everyone ought to recognise and use. It allows localisation and shortened dialling, but Nokia just want a number string. It's just lazy on thepart of the programmers; since it's a standard, they should have developed the program code once and just inserted it into every phone they produce, and that's not hard.
    A poor reflection on Nokia, I'm sad to say.
    AFAIK the international standard for telephone numbers (E.164) does not say anything about using spaces, dashes, or brackets in a telephone number.
    This may of course make it more "human readable", but claiming that what you want is a standard doesn't make it a standard, and I don't think Nokia (or any other phone manufacturer) should/could implement every single user-specific wish...

  • How to remove duplicate phone numbers under iMessage settings?

    I've been using iMessage for a while now and a lot of my friends have brought to my attention that every iMessage I sent showed it came from my email rather than my phone number. So I signed out of iMessage and tried logging back in using my phone number and it would not work, saying the activation did not go through. So I tried again and again throughout the day and it finally worked eventually. The problem is I get a duplicate (lots of it) of my phone numbers, I'm guessing from my countless attempts at signing in. How do I go about removing all the duplicates that are grayed out? Also why do the last three have tick marks next to them? How do I make it so that only one of them is tickmarked and delete the rest of the duplicates. I've provided screenshots below.
    Also, "waiting for activation..." has been shown under the settings for almost the whole day. How long does this take?

    I've tried signing out and back in again. It doesn't do anything. I still get the unnecesarily long list of duplicate phone numbers and have 2 or 3 of them randomly tick marked. I've tried this multiple times, it doesn't get rid of them at all. As far as I'm concerned, my friends do receive my iMessage from my number rather than my email. I just find it a nuisance to have such a long list of my phone number 25 times over. I don't think it affects anything though, but any way to get rid of them would be great.
    Also, it's been 3 days and it still says "waiting for activation" on my iMessage and Facetime settings. How long does this take? As far as I know, my friends have told me iMessaging with me is flawless but I'm confused as to why it's still trying to activate.

  • How do I highlight phone numbers, in documents such as .pdf or pages or numbers, so I can call that number simply by touching that number?

    I save a document into my iPhone 6's pdf reader, such as a pages, word, excel doc   Sometimes the phone numbers are highlighted, so that I can call the number just by touching that number.  Other times the phone numbers are not "live."  How do I make the phone numbers work?

    If I go to my notes app ( not a note in a contact) and I add a phone number and tap done the number becomes live.  However if I then copy the live number from the notes app and try and paste it into the notes field in a contact it is no longer live.  Weird huh

  • Is there any way to turn off Contacts' automatical formating of phone numbers?

    Address Book's telephone fields used to be free text. You could format the phone number as desired and add comments if needed. Contacts automatically format phone number according to the ten-digit phone number (area code plus 7 digit number). If the content of a phone field does not conform to this format, the contents are all pushed together, removing any spaces that you may have entered.
    In many countries that required formating is inappropriate. Besides, it limits your freedom to add important details, like "Do not call after 7PM," etc.
    There seems no way to turn this automatical formating.

    The format for South African numbers is wrong!
    Contacts uses: +27 (xx) yyyyyyy
    Firstly the dialing code is no longer optional (for at least five years) so the brackets make no sense. Also, almost everyone uses the grouping of 3 digits then 4 digits - including official phone books.
    Its should be +27 xx yyy zzzz
    (I would also like the the auto-formatting to be optional as some other countries are crazy too).
    Is posting something here enough to get the attention of developers?

  • How do i display phone numbers from Contacts in large type?

    The phone numbers displayed in Contacts are difficult to read for old eyes.  How do I display them in a large font size so I can read them without glasses?  Is there a setting or an alternate app that can do that?

    The only thing that I know of is Settings -> General ->Accessability -> Zoom
    With that on, when you tap the screen twice using 3 fingers, the whole screen zooms.  I've tried the "Large Text" feature, but it does nothing to the phone numbers in contacts, just the text portions.

  • How do I change phone numbers associated with an iPad?

    How do I change phone number associated with my iPad?

    Obviously you must have an iPhone in order to associate the phone number with the FaceTime and Messages apps on your iPad. You haven't clearly stated what you want to do other than associate a phone number, so I assume these are the two apps that you want to associate the phone number with.
    If you are unable to add the phone number in the settings in either or both of these apps, you may have to sign out of both apps on the Phone and the iPad - and then sign in again on both devices in order to use the phone number for FaceTime and Messages on the iPad.
    This kb article explains how to do this in more detail.
    http://support.apple.com/kb/HT5538

  • HT204053 how do i remove phone numbers from my apple id

    Have multiple phone numbers attached to one Apple ID and want to remove them.

    See "Unlink a phone number" under "Additional Information" at the bottom of this article: http://support.apple.com/kb/HT5538.

  • How can I make phone numbers in my mail signature clickable ie recipient can phone me with one click on the number

    I'm using OSX 10.9.3.
    I use Mail on all my devices.
    In the email signature I have my two phone numbers.
    Is it possible to make them live so that recipients can click on the numbers to call me, straight from the email?
    thanks
    Juliet

    Most, if not all, Smart Phones will recognize phone numbers and allow you to call. On every other device, it doesn't make much sense to have a link as it wouldn't work on a computer that doesn't have some built-in telephony system.
    However, you can embed an html link like this: http://code.tutsplus.com/tutorials/mobile-web-quick-tip-phone-number-links--mobi le-7667

Maybe you are looking for

  • 0CO_OM_OPA_6 creation time for delta Q in R/3

    Hi all, Once a month a job on R/3 runs to generate the actual costs/billing for CS-orders. These are then picked up by datasource 0CO_OM_OPA_6 for transfer to BW where the month-end reports can be made. The monthly R/3 job runs on the 4th of each mon

  • Failed to launce HDMI connection when connection Notebook to TV

    Dear All, I have a problem connecting my PC to the TV using a HDMI-cabel since I installed windows8 My PC: HP Pavilion dv6-3160sd Entertainment Notebook PC operating system: Windows 8 I tried to search for drivers that I needed to install or somethin

  • Oracle 10.2.0.4 RAC vip故障漂移导致监听关闭.

    环境:oracle 10.2.0.4 RAC+ASM 故障现象:vip漂移至另一节点导致监听关闭,vip漂移现象随机在2个节点中出现,数据库实例正常,只是vip漂移至另一节点,同时监听offline. # su - oracle $ crs_stat -t Name Type Target State Host ora....SM1.asm application ONLINE ONLINE p770db1 ora....B1.lsnr application ONLINE OFFLINE or

  • I want cond type JIP5 used for vat reimbursable to be printed in PO

    Hi Experts, In our organization we are addressing vat reimbursable part by using tax code say R2, which is being chosen in invoice tab of item detail section in PO. The condition type used JIP5 using taxinj, but when we take printout of the PO this c

  • 4 speaker surround sound

    Is there a 3rd party app or something for taking the microphone in on the MacBook Pro and converting it to an audio out for 4 speaker surround sound? My windows machine (ya, I know...I am a mac convert but I haven't gotten to the part where I buy my