Hello..I have existing data in a #temp table
I would like to capture the recordid and all of the associated names (separated by a semicolon) into one column. Something like this in a #temp2 table or something
RECORDID, NAMES
1, NAME1;NAME2;NAME3
2, NAME1;NAME2
3, NAME1
4, NAME1;NAME2;NAME3
Is it possible to do this in SQL 2000? I kind of have a dim-witted way to do it with a ton of joins and temp tables but never can adjust correctly for the different numbers of names with each recordid.
Thanks!
Code:
create table #temp (recordid int, name varchar(200))
insert into #temp values (1, 'NAME1')
insert into #temp values (1, 'NAME2')
insert into #temp values (1, 'NAME3')
insert into #temp values (2, 'NAME1')
insert into #temp values (2, 'NAME2')
insert into #temp values (3, 'NAME1')
insert into #temp values (4, 'NAME1')
insert into #temp values (4, 'NAME2')
insert into #temp values (4, 'NAME3')
I would like to capture the recordid and all of the associated names (separated by a semicolon) into one column. Something like this in a #temp2 table or something
RECORDID, NAMES
1, NAME1;NAME2;NAME3
2, NAME1;NAME2
3, NAME1
4, NAME1;NAME2;NAME3
Is it possible to do this in SQL 2000? I kind of have a dim-witted way to do it with a ton of joins and temp tables but never can adjust correctly for the different numbers of names with each recordid.
Thanks!