Stuart Ainsworth shares a client case of importing XML documents into a staging table and what he learned about using XQuery methods in SQL Server.
Sending an HTML Table by Email With sp_send_dbmail
Turn a wall of report text into a clean table. FOR XML PATH escapes your data, and a few small tricks handle NULL values and empty days.
XQuery Comparisons: General Equality Is Not Singleton Equality
XQuery Comparisons use different rules for general sequence operators and singleton value operators. I make equality and inequality visible side by side. A general unequal-pair result is not always the inverse of an equal-pair result.
SQL SERVER – Group by Rows and Columns using XML PATH – Efficient Concating Trick
A reader wanted students and courses grouped by course and instructor in a single row. Here is a simple concatenation trick with XML PATH that does it.
STRING_AGG Limits: The 8,000 Byte Error, Ordering and Duplicates
Fix STRING_AGG 8,000-byte limits, enforce ordering, remove duplicates before aggregation, and compare its timing with XML.
SQL SERVER – Grouping by Multiple Columns to Single Column as A String
How do you group data from multiple columns into one comma separated string per row, grouped by another column? Here is a sample dataset and the query.
Checking XML Index Size Against the Table It Belongs To
An XML index can outweigh the table it serves. Here is how I measure each XML structure next to the base table, and what to test before dropping one.







