Skip to content

Instantly share code, notes, and snippets.

@bojanbjelic
Created May 29, 2013 09:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bojanbjelic/5669203 to your computer and use it in GitHub Desktop.
Save bojanbjelic/5669203 to your computer and use it in GitHub Desktop.
sql server csv
SELECT distinct
SUBSTRING((SELECT ',' + CAST(countryId as VARCHAR)
FROM countries_regions where countries_regions.regionId = regions.id
FOR XML PATH('')), 2, 20000) AS CSV, regions.id
FROM countries_regions
inner join regions ON countries_regions.regionId = regions.id
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment