Skip to content

Instantly share code, notes, and snippets.

@fesenpav
Created September 14, 2022 20:06
Show Gist options
  • Save fesenpav/766c9a4032d6a48c776f645a9876e726 to your computer and use it in GitHub Desktop.
Save fesenpav/766c9a4032d6a48c776f645a9876e726 to your computer and use it in GitHub Desktop.
Useful stuff for displaying a column in SQL within a single string, values separated by commas
STUFF(
(
SELECT ', ' + mt.[TextValue]
FROM dbo.[MultiSelect] AS ms
LEFT JOIN usr.[MonthType] AS mt ON mt.[Ident] = ms.[Value] AND mt.[LanguageID] = @UserLanguageID
WHERE
ms.[TableID] = at.[ID]
AND ms.[FormIdent] = @FormIdent
AND ms.[ControlIdent] = @ControlIdent
FOR xml path('')
),
1,
1,
''
) AS Month,
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment