Created
March 2, 2017 20:00
-
-
Save aramkoukia/12b32c294f9d1b95dc9d5942f5421891 to your computer and use it in GitHub Desktop.
STUFF-XPATH comma separate rows
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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