Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save NPS-ARCN-CAKN/93396938baa24c446c376038b94214b5 to your computer and use it in GitHub Desktop.
Save NPS-ARCN-CAKN/93396938baa24c446c376038b94214b5 to your computer and use it in GitHub Desktop.
Sql: Select distinct values into comma separated list
DECLARE @Packs AS NVARCHAR(MAX)
select @Packs = STUFF((SELECT DISTINCT ',' + QUOTENAME(LTRIM(RTRIM(Pack))) from basequeryTotalPupsByRegion FOR XML PATH(''), TYPE).value('.', 'NVARCHAR(MAX)'),1,1,'')
select @Packs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment