Skip to content

Instantly share code, notes, and snippets.

@chadbaldwin
Created November 13, 2023 22:17
Show Gist options
  • Save chadbaldwin/39a8f40e12f83928815b8138afb31610 to your computer and use it in GitHub Desktop.
Save chadbaldwin/39a8f40e12f83928815b8138afb31610 to your computer and use it in GitHub Desktop.
SQL Server STRING_AGG bug
SELECT TOP(100) t.[name], c.TestA, c.TestB
FROM sys.tables t
CROSS APPLY (
SELECT TestA = STRING_AGG(c.[name], '_')
, TestB = STRING_AGG(c.[name], ',')
FROM sys.columns c
WHERE c.[object_id] = t.[object_id]
) c
WHERE t.is_ms_shipped = 1
ORDER BY t.[object_id]
@chadbaldwin
Copy link
Author

[reserving first comment]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment