Applies To: SQL Server 2014, SQL Server 2016 Preview
Returns information about active handles that have been opened by sp_xml_preparedocument.
Applies to: SQL Server (SQL Server 2008 through current version), SQL Database V12.
- session_id | 0,
ID of the session. If session_id is specified, this function returns information about XML handles in the specified session.
If 0 is specified, the function returns information about all XML handles for all sessions.
Session ID of the session that holds this XML document handle.
XML document handle ID returned by sp_xml_preparedocument.
Internal handle ID used for the associated namespace document that has been passed as the third parameter to sp_xml_preparedocument. NULL if there is no namespace document.
Handle to the text of the SQL code where the handle has been defined.
Number of characters into the currently executing batch or stored procedure at which the sp_xml_preparedocument call occurs. Can be used together with the sql_handle, the statement_end_offset, and the sys.dm_exec_sql_text dynamic management function to retrieve the currently executing statement for the request.
Number of characters into the currently executing batch or stored procedure at which the sp_xml_preparedocument call occurs. Can be used together with the sql_handle, the statement_start_offset, and the sys.dm_exec_sql_text dynamic management function to retrieve the currently executing statement for the request.
Timestamp when sp_xml_preparedocument was called.
Size of the unparsed XML document in bytes.
Size of the unparsed XML namespace document, in bytes. NULL if there is no namespace document.
Number of OPENXML calls with this document handle.
Number of rows returned by all previous OPENXML calls for this document handle.
Milliseconds since the last OPENXML call. If OPENXML has not been called, returns milliseconds since the sp_xml_preparedocument call.
The lifetime of sql_handles used to retrieve the SQL text that executed a call to sp_xml_preparedocument outlives the cached plan used to execute the query. If the query text is not available in the cache, the data cannot be retrieved using the information provided in the function result. This can occur if you are running many large batches.
Requires VIEW SERVER STATE permission on the server to see all sessions or session IDs that are not owned by the caller. A caller can always see the data for his or her own current session ID.
The following example selects all active handles.
SELECT * FROM sys.dm_exec_xml_handles(0);