Possible Duplicate:
SQL Server: Can I Comma Delimit Multiple Rows Into One Column?
SQL Query to get aggregated result in comma seperators along with group by column in SQL Server
I have a table similar to this:
DocumentID Name
1 Jack D'Souza
1 Rick Astley
1 Frankestein
1 Einstein
I want to write a SQL Server scalar function which would accept in parameter as DocumentID and give a CSV separated value. So, If I pass in 1
, it would give Jack D'Souza, Rick Astley, Frankestein, Einstein
Inside the function, I can create in cursor and create this CSV list. But is there any alternative to using cursor?