Quantcast
Channel: SQLServerCentral » SQL Server 2014 » Development - SQL Server 2014 » Latest topics
Viewing all articles
Browse latest Browse all 3145

Remove first 2 digit and change phonenumber format SQL

$
0
0
hi,I have a tableA in which PhoneNumber column have values like 911234567891.i want to remove the first two digits from the start i.e 1234567891 and then i want to change it to phone number format xxx-xxx-xxxx so the ending result will be 123-456-7891.I have already done it using seprate Select and Update query like this: [code="sql"]SELECT [Phone Numbers] ,FORMAT([Phone Numbers],'###-###-####') AS [Formatted Phone] FROM tbl_sampleUPDATE tbl_sample SET [Phone Numbers] = SUBSTRING([Phone Numbers], 3, 8000) WHERE [Phone Numbers] LIKE '91%'[/code]Is it possible to do it using single select query only so that there will be no need to update the data first?Any kind of help or suggestion will be appreciated.

Viewing all articles
Browse latest Browse all 3145

Trending Articles