Mistake: treating OPENXML() as a self-contained parser. sp_xml_preparedocument parses XML through an MSXML parser and returns a handle to an in-memory node tree that OPENXML() can consume. section 3.4.1
The cleanup mistake
A shredding routine can prepare a document, pass its handle to OPENXML(), and forget cleanup. Always call sp_xml_removedocument afterward so the in-memory document does not continue consuming memory. section 3.4.1
Use the procedure as part of a complete XML-shredding sequence:
- Prepare the XML document before passing its handle to OPENXML(). section 3.4.1
- Remove the prepared document after OPENXML() finishes. section 3.4.1
