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.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 concatinate - with example [RESOLVED]

Author  Topic 

Pace
Constraint Violating Yak Guru

264 Posts

Posted - 2008-10-21 : 11:22:13
Hi All,

Ive seen this before, I just cant remember how to do it, can someone help?

ID TYPE TEXT
1 1 A
2 1 B
3 2 C
4 2 D



ID TYPE TEXT
1 1 A,B
2 2 C,D



"Impossible is Nothing"

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-10-21 : 11:24:49
[code]SELECT t.TYPE,LEFT(tl.txtlist,LEN(tl.txtlist)-1)
FROM(SELECT DISTINCT TYPE FROM Table)t
CROSS APPLY (SELECT TEXT + ','
FROM Table
WHERE TYPE=t.TYPE
FOR XML PATH(''))tl(txtlist)[/code]
Go to Top of Page

Pace
Constraint Violating Yak Guru

264 Posts

Posted - 2008-10-21 : 11:31:36
Thank you so much

"Impossible is Nothing"
Go to Top of Page
   

- Advertisement -