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 |
|
jayanth_jyothi
Starting Member
11 Posts |
Posted - 2009-02-13 : 10:24:45
|
| Hi,For example in one table data is like thisAssociateID RelatedID Relationship ----------- --------- ------------1234 4567 Passenger1234 4567 Emergency ContactSo the above data i want make like belowAssociateID RelatedID Relationship ----------- --------- ------------1234 4567 Passenger,Emergency ContactCan some body provide me T-SQL for the above caseThanks in Advance |
|
|
jayanth_jyothi
Starting Member
11 Posts |
Posted - 2009-02-13 : 10:47:51
|
| AssociateID RelatedID Relationship ----------- --------- ------------1234 4567 Passenger1234 4567 Emergency ContactSo the above data i want make like belowAssociateID RelatedID Relationship ----------- --------- ------------1234 4567 Passenger,Emergency ContactCan some body provide me T-SQL for the above caseas i need to display the grid in above format |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-02-13 : 11:02:46
|
| [code]SELECT DISTINCT t.AssociateID ,t.RelatedID,STUFF((SELECT ',' + Relationship FROM Table WHERE AssociateID =t.AssociateID AND RelatedID =t.RelatedID FOR XML PATH('')),1,1,'') AS Relationship FROM Table t[/code] |
 |
|
|
jayanth_jyothi
Starting Member
11 Posts |
Posted - 2009-02-13 : 12:16:00
|
| Thanks Visakh |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-02-13 : 12:36:55
|
| welcome |
 |
|
|
|
|
|