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:
xmlextract() returns the data identified by a single XPath query.
xmltable() extracts the sequence, or row pattern, of the data identified by an XPath query, and extracts from each element of that sequence the data identified by a list of other XPath queries, the column patterns. It returns all the data in a SQL table.