Monday, September 20, 2010

MSSQL alternative to MySQL's GROUP_CONCAT

Here's a MSSQL equivalent of the group_concat()  from MySQL:
DECLARE @itemFields varchar(MAX)
SELECT  @itemFields = COALESCE( @itemFields + ',', '') + QUOTENAME([fi].[Name])     
FROM [forms_items] fi     
GROUP BY [fi].[Name]

No comments:

Post a Comment