SQL Server emergency? Email pinal@sqlauthority.com with URGENT in the subject line.

sp_xml_preparedocument: Prepare XML in Memory and Always Release It

sp_xml_preparedocument parses an XML document into memory and returns a handle that OPENXML can read. This post shows the safe pattern with TRY and CATCH, why the handle number is not yours to choose, what happens when you reuse a released handle, and how the WITH clause and flags shape the rows. Every result comes from SQL Server 2025.

Continue Reading