sql query modify

Hi,

In my report phone numbers are getting like this

7734300668

7734902372

2242167573

but client asking phone numbers this format

(773) 430-0668
(773) 490-2372
(224) 216-7573

So please solve this anyone

June 18th, 2015 3:03am

DECLARE @ph AS VARCHAR(30)='7734300668'

SELECT 
STUFF('('+STUFF(@ph,7,0,'-'),5,0,')')
Free Windows Admin Tool Kit Click here and download it now
June 18th, 2015 3:15am

Hello - You can try this:

DECLARE @Phone_Number AS VARCHAR(20)='7734902372'
SELECT '('+LEFT(@Phone_Number,3) + ') ' + substring(@Phone_Number,4,3) + '-' + RIGHT(@Phone_Number,4)

Hope this h

June 18th, 2015 3:38am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics