Is there another way to do this without the XML function? I've tried following Concatenate many rows into a single text string? I'm having issues trying to run this on SQL Server 2008 R2.
Conversion failed when converting the varchar value ',' to data type int.
Select distinct ST2.id
substring(
(
Select ','+ST1.id AS [text()]
From dbo.idstable ST1
Where ST1.id = ST2.id
ORDER BY ST1.id
For XML PATH ('')
), 2, 1000) [idstable]
From dbo.idstable ST2