A Recipes table with a Labels column of type xml: Mint Tea has two labels, Garden Salad three, Plain Rice an empty Labels element, Berry Smoothie one, and Bread and Butter has NULL because nobody has looked yet

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.

Read More