Last active
May 1, 2018 18:53
-
-
Save shaisachs/d6c04a715d6eb2aa8aa56bb01a6b65c9 to your computer and use it in GitHub Desktop.
TSQL rows to csv
This file contains 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
-- from https://stackoverflow.com/questions/887628/convert-multiple-rows-into-one-with-comma-as-separator | |
select * | |
into #tmpdata | |
from things | |
where thingid >= 100 and thingid <= 200 | |
declare @answer varchar(1000) = '' | |
select @answer = @answer + id + ', ' from #tmpdata | |
select @answer |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment