The script I use most often to build Comma Separated Values (CSV) from a table column with FOR XML PATH. I think XML is the best option for code and speed.
XQuery string-length: Count Content Without Markup
XQuery string-length counts the selected element string value. Seven bounded cases separate content from markup, empty elements from missing elements, and missing XML from existing documents.
FOR XML PATH: Choose Attributes and Nested Elements With Aliases
FOR XML PATH interprets column aliases as directions for the output’s attributes and element hierarchy. I use three aliases to shape two rows. The source columns stay ordinary relational values.
SQL SERVER – Practical SQL Server XML: Part One – Query Plan Cache and Cost of Operations in the Cache
A guest post from Michael Coles, author of Pro SQL Server 2008 XML: a practical XML demo that looks at the query plan cache and the cost of cached operations.
SQL SERVER – Simple Example of Reading XML File Using T-SQL
A simple example of reading XML file content using T-SQL: load the XML into a variable and pull out elements and attributes with value() in a SELECT.
SQL SERVER – Simple Example of Creating XML File Using T-SQL
I always want to learn SQL Server and XML file. Let us go over a very simple example, today about how to create XML using SQL Server.
XML Compression in SQL Server 2022
Use XML compression in SQL Server 2022 to reduce XML storage, inspect partition settings, and compare CPU costs on your own workload.






