Is there an Implode type function for SQL Server?
What I have is a list (in a SQL server table):
Apple
Orange
Pear
Blueberry
a
I typically use the FOR XML PATH method for this, it works for row subqueries as well, simply
SELECT ', ' +
FROM
ORDER BY
FOR XML PATH('')
This will give you your list with a ", " at the start, and the quickest way to remove that
is to use stuff
SELECT STUFF((
SELECT ', ' +
FROM
ORDER BY
FOR XML PATH('')
),1,2,'')