Created
November 20, 2019 14:04
-
-
Save jasoncable/21462a72706c6544a73bc4cdc4c603f6 to your computer and use it in GitHub Desktop.
T-SQL - Comma-seperated list from subselect (one to many)
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 d.*, | |
stuff((select ', ' + f.Name | |
from FolderItem fi | |
join Folder f on fi.FolderId = f.FolderId | |
where d.DocumentId = fi.DocumentId | |
for xml path('')), 1, 2, '') as folders | |
from Document d |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment