How do I avoid character encoding when using “FOR XML PATH”?
You just need to use the right options with FOR XML. Here’s one approach that avoids encoding: USE tempdb; GO CREATE TABLE dbo.x(y nvarchar(255)); INSERT dbo.x SELECT ‘Sports & Recreation’ UNION ALL SELECT ‘x >= y’ UNION ALL SELECT ‘blat’ UNION ALL SELECT ‘<hooah>’; — BAD: SELECT STUFF((SELECT N’,’ + y FROM dbo.x FOR XML … Read more