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.
| Author |
Topic |
|
ArpitNarula
Starting Member
16 Posts |
Posted - 2011-03-01 : 03:28:07
|
| Hi Guys,Below is the scenerio:Table A Name BUA 1A 2A 3B 2C 1C 3 Output Name BUA 1,2,3B 2C 1,3Thanks in Advance |
|
|
Ranjit.ileni
Posting Yak Master
183 Posts |
Posted - 2011-03-01 : 04:02:53
|
| check it once....create table #TableA ( Name varchar(10), BU int)goinsert into #TableAselect 'A',1 union allselect 'A', 2 union allselect 'A', 3 union allselect 'B', 2 union allselect 'C', 1 union allselect 'C', 3goselect Name ,stuff((select ',' + cast(BU as varchar(25)) from #TableA a where a.Name = b.Name for xml path('')), 1, 1, '') as BUfrom #TableA bgroup by Name--Ranjit |
 |
|
|
ArpitNarula
Starting Member
16 Posts |
Posted - 2011-03-01 : 05:07:34
|
| Thanks Ranjit...It Worked!But if you can also guide me/or provide a link which explains how this syntax works that would be great. |
 |
|
|
Ranjit.ileni
Posting Yak Master
183 Posts |
|
|
|
|
|
|
|