Home Forums SQL Server 2005 T-SQL (SS2K5) CTE RE: CTE
Lynn Pettis
SSC Guru
Points: 442467
More actions
April 14, 2010 at 1:20 pm
#1151676
Here is my code:
select distinct
reportID,
RoleID,
stuff((select ', ' + t2.User2
from #tbl t2
where t2.reportID = t1.reportID and t2.RoleID = t1.RoleID
for xml path('')),1,2,'') as List
from #tbl t1;