Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 separate values from 1 field to a column

Author  Topic 

oldfox
Starting Member

17 Posts

Posted - 2010-08-13 : 14:26:45
I have list with a country code in the first column and area codes in the second column separated by comma.
I need to create list with unique country code + area code combination's.
It has to be like this
Country Area
44 78
44 79
44 80

Thank you.


drop table #my_list
create table #my_list
(cc_prefix numeric,
CityCountry varchar(200))

insert into #my_list values (44,'78,79,80')
select * from #my_list

vijayisonly
Master Smack Fu Yak Hacker

1836 Posts

Posted - 2010-08-13 : 14:36:24
You can use a split function. Search this forum for split functions, there are lots of versions.

EDIT : Try fnParseList from here

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=76033#315323
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-08-14 : 00:34:21
http://visakhm.blogspot.com/2010/02/parsing-delimited-string.html

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -