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 |
|
khalik
Constraint Violating Yak Guru
443 Posts |
Posted - 2009-01-13 : 03:28:57
|
| Hi I have a table which has person wise color. table structuredeclare @test table ( Person varchar(100), color varchar(100))insert into @testselect 'Tom','Green' union allselect 'Tom','Yelloq' union allselect 'Tom','Blue' union allselect 'Samy','Blue' union allselect 'Samy','Black' union allselect 'K','White' i expected output shd be Tom Green,Yellow,BlueSamy Blue,BlackK whitecan be done using simple qrythanks======================================Ask to your self before u ask someone |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
|
|
bklr
Master Smack Fu Yak Hacker
1693 Posts |
Posted - 2009-01-13 : 03:53:22
|
| select distinct Person , stuff((select ','+ color from @test where Person = e.Person for xml path('')),1,1,'') from @test eorder by person desc |
 |
|
|
khalik
Constraint Violating Yak Guru
443 Posts |
Posted - 2009-01-13 : 04:05:08
|
| Thanks BKlr and Peso======================================Ask to your self before u ask someone |
 |
|
|
|
|
|
|
|