February 5, 2010 at 1:22 pm
Hi,
Here is what i have
CId, SN
1, ABC1
1, AAA2
1, BCV3
2, XYZ1
2, MMM1
Here is what i need
Id SNs
1, ABC1,AAA2,BCV3
2, XYZ1,MMM1
How?
Thanks
February 5, 2010 at 1:32 pm
Something like this, I would guess.
create table #testtab (
CId int,
SN char(4)
);
insert into #testtab
select 1, 'ABC1' union all
select 1, 'AAA2' union all
select 1, 'BCV3' union all
select 2, 'XYZ1' union all
select 2, 'MMM1';
select distinct
CId,
STUFF((select ',' + SN from #testtab tt2 where tt2.CId = tt1.CId for xml path('')),1,1,'')
from
#testtab tt1;
February 5, 2010 at 1:42 pm
Thanks Lynn, you are the best
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