The xmltable() Function

xmltable() creates a SQL table from elements in an XML table.

xmltable() extracts a sequence of multivalued elements from an XML document, and assembles a SQL table of those elements. A single call to xmltable() replaces a Transact-SQL loop that performs multiple calls to xmlextract() on each iteration. xmltable() is invoked as a derived table (a parenthesized subquery specified in the from clause of a different SQL query). Calling xmltable() is equivalent to executing a single xmlextract() expression for each row of the table generated by xmltable().

xmltable() is a generalization of xmlextract(). Both functions return data extracted from an XML document that is an argument in the function. The differences are: