In SQL Server, OPENXML() does not parse XML itself. Prepare the document with sp_xml_preparedocument, which returns a handle to an in-memory tree of its nodes. section 3.4.1
Mistake: prepare the document and forget cleanup. Call sp_xml_removedocument after OPENXML() to release the memory consumed by the parsed representation. section 3.4.1
Employee contract data
An EmployeeContracts document nests employees, contracts, and repeating skills. OPENXML() can shred these levels into relational contract and skill data, using XPath to select rows and ../ to reach parent nodes. section 3.4.1
Apply the parser workflow carefully:
- Prepare the XML, pass its handle to OPENXML(), then remove the document. section 3.4.1
