Skip to content

Instantly share code, notes, and snippets.

@DoubleBrotherProgrammer
Created May 11, 2010 22:01
Show Gist options
  • Save DoubleBrotherProgrammer/397942 to your computer and use it in GitHub Desktop.
Save DoubleBrotherProgrammer/397942 to your computer and use it in GitHub Desktop.
Use AdventureWorks
-- fill up temp table 1 ( [Schema], [Event] )
SELECT DISTINCT [Schema], [Event]
INTO #tempTbl1
FROM DatabaseLog
ORDER BY [Schema], [Event]
-- create delimited list
SELECT [Schema],
Events = STUFF(
(
SELECT ',' + [Event]
FROM #tempTbl1 mp2
WHERE mp2.[Schema] = mp1.[Schema]
FOR XML PATH('')
), 1, 1, '' )
FROM #tempTbl1 mp1
GROUP BY mp1.[Schema]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment