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.
Add an XML Column to a Table: One Row, Many Related Values
To add an XML column to a table, use ALTER TABLE with the xml data type, and each row can then carry a list of related values. This post adds a Labels column to a Recipes table, fills it, checks that bad XML is refused, and asks questions with value() and exist(). It then builds the same data as a child table and compares what each design can enforce. Every result comes from SQL Server 2025.
nodes() Method in SQL Server: Aliases and Row Patterns
The nodes() method turns each element at a path into one row you can query. This post builds a small catalog of books and reviewers, and shows the two alias errors, query() against value(), the singleton rule, how the row pattern decides the rows, and CROSS APPLY for the next level. Every result comes from SQL Server 2025.
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.







