August 15, 2006 at 6:01 pm
I have an area code column and a phone number column that I would like to "merge" into one column for better management and reporting? This seems like it should be simple enough but can't seem to find any trick to doing this. Any suggestions?
Thanks
Ron
Edit..This is in SQL Server 2000
August 15, 2006 at 6:38 pm
What have you tried and what difficulties have you run into?
It would seem that all you need to do is add a column to the table (e.g., AreaPhone), then run an update that concatenates the data from the orignal columns into the new columns. Something like
update PhoneTable
Set AreaPhone = AreaCode + PhoneNumber
August 15, 2006 at 7:20 pm
Having been in the telecommunications world for about 11 years, lemme just say...
DON'T COMBINE THE NPA AND NXX COLUMNS!!!!!!!! You will hate yourself so bad in the future for more reasons than I have the room to post on this forum. Also, don't combine the NPA with the 7 digit NXX/LINE column combination.
Instead, create a calculated column with something like the formula that Andrew used...
--Jeff Moden
Change is inevitable... Change for the better is not.
August 15, 2006 at 7:54 pm
I should have been more clear, I do want a third column that is the combination of the two. Thanks for the suggestions!
August 16, 2006 at 1:09 am
Then do as Jeff says, and make that column a computed column.
/Kenneth
August 17, 2006 at 8:48 am
Andrew,
This literally added the columns (ie mathmatically) instead of concatenating them.
I have tried the following:
update PhoneTable
Set AreaPhone = (AreaCode & PhoneNumber)
with no luck either.
Other suggestions?
Thanks
August 17, 2006 at 10:56 am
Ron,
I think the two columns (AreaCode & PhoneNumber) are of type int, thats why concatenation is not happening
try this
update
PhoneTable
set
AreaPhone =rtrim(convert(char,AreaCode))+convert(char,PhoneNumber)
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply