July 10, 2001 at 2:22 pm
Hi Steve
Can you show me how to CONVERT Phone Number int(10) to nvchar (14)
ie: 7039225903 to (703) 922-5903. Thank you.
S Ryan
steve ryan
steve ryan
July 10, 2001 at 3:43 pm
select '(' + substring( phone, 1, 3) + ') ' + substring( phone, 4, 3) + '-' + substring(phone, 7, 4)
Steve Jones
July 10, 2001 at 10:23 pm
Couple questions. How do you get an int to hold that value? The max value is 2,147,483,648 (or (214) 748-3648 as a phone number!) Another question is why did you store it as a number?
Also, I think Steve left out a step - have to convert it to a string somewhere, either inline or before as I've done here. (NOTE: I suspect this was a subtle trap Steve slyly planted to see if we are paying attention)
declare @Phone bigint
declare @NewPhone nvarchar(10)
set @Phone=7039225903
set @NewPhone=convert(nvarchar(12), @Phone)
select '(' + substring(@newphone, 1, 3) + ') ' + substring(@newphone, 4, 3) + '-' + substring(@newphone, 7, 4)
Andy
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy