February 4, 2015 at 6:14 am
I have a table T1 with only one column.
ID
1
2
3
I want to put all the records (separated by comma) in a single column of another table T2.
ID
1,2,3
Is it possible to do this without using the cursors?
Thank you.
February 4, 2015 at 6:27 am
You might be able to use this technique:
declare @T1 table (Id int)
insert @T1
(Id)
values (1),(2),(3);
with vals(x) as (select ',' + cast(Id as varchar(5)) from @T1 t
for xml path(''))
select stuff(x,1,1,'') from vals
If you haven't even tried to resolve your issue, please don't expect the hard-working volunteers here to waste their time providing links to answers which you could easily have found yourself.
February 4, 2015 at 8:22 am
For an explanation on what Phil posted.
http://qa.sqlservercentral.com/articles/comma+separated+list/71700/
February 16, 2015 at 7:24 am
thank you very much
February 18, 2015 at 2:59 am
Thank you Phil, very useful!
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply