| title | sp_xml_removedocument (Transact-SQL) | ||
|---|---|---|---|
| description | Removes the internal representation of the XML document specified by the document handle and invalidates the document handle. | ||
| author | markingmyname | ||
| ms.author | maghan | ||
| ms.reviewer | randolphwest | ||
| ms.date | 06/23/2025 | ||
| ms.service | sql | ||
| ms.subservice | system-objects | ||
| ms.topic | reference | ||
| ms.custom |
|
||
| f1_keywords |
|
||
| helpviewer_keywords |
|
||
| dev_langs |
|
[!INCLUDE SQL Server Azure SQL Database Azure SQL Managed Instance FabricSQLDB]
Removes the internal representation of the XML document specified by the document handle and invalidates the document handle.
A parsed document is stored in the internal cache of [!INCLUDE ssNoVersion]. The MSXML parser (msxmlsql.dll) uses one-eighth the total memory available for [!INCLUDE ssNoVersion]. To avoid running out of memory, run sp_xml_removedocument to free up the memory.
:::image type="icon" source="../../includes/media/topic-link-icon.svg" border="false"::: Transact-SQL syntax conventions
sp_xml_removedocument hdoc
[ ; ]
[!INCLUDE extended-stored-procedures]
The handle to the newly created document. A handle that isn't valid returns an error. hdoc is an integer.
0 (success) or > 0 (failure).
Requires membership in the public role.
The following example removes the internal representation of an XML document. The handle to the document is provided as input.
EXECUTE sp_xml_removedocument @hdoc;