Skip to content

Instantly share code, notes, and snippets.

@aramkoukia
Created March 2, 2017 20:00
Show Gist options
  • Select an option

  • Save aramkoukia/12b32c294f9d1b95dc9d5942f5421891 to your computer and use it in GitHub Desktop.

Select an option

Save aramkoukia/12b32c294f9d1b95dc9d5942f5421891 to your computer and use it in GitHub Desktop.
STUFF-XPATH comma separate rows
SELECT STUFF((
SELECT ','+ cast(Color AS nvarchar(255))
FROM NameColorTable b
WHERE a.Name = b.Name
FOR XML PATH('')),1,1,'') AS COLUMN2
FROM NameColorTable a
GROUP BY a.Name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment