SPID query plan

SELECT EQP.query_plan,
       ER.session_id,
       ER.request_id,
       ER.start_time,
       ER.status,
       ER.command,
       ER.sql_handle,
       ER.statement_start_offset,
       ER.statement_end_offset,
       ER.plan_handle,
       ER.database_id,
       ER.user_id,
       ER.connection_id,
       ER.blocking_session_id,
       ER.wait_type,
       ER.wait_time,
       ER.last_wait_type,
       ER.wait_resource,
       ER.open_transaction_count,
       ER.open_resultset_count,
       ER.transaction_id,
       ER.context_info,
       ER.percent_complete,
       ER.estimated_completion_time,
       ER.cpu_time,
       ER.total_elapsed_time,
       ER.scheduler_id,
       ER.task_address,
       ER.reads,
       ER.writes,
       ER.logical_reads,
       ER.text_size,
       ER.language,
       ER.date_format,
       ER.date_first,
       ER.quoted_identifier,
       ER.arithabort,
       ER.ansi_null_dflt_on,
       ER.ansi_defaults,
       ER.ansi_warnings,
       ER.ansi_padding,
       ER.ansi_nulls,
       ER.concat_null_yields_null,
       ER.transaction_isolation_level,
       ER.lock_timeout,
       ER.deadlock_priority,
       ER.row_count,
       ER.prev_error,
       ER.nest_level,
       ER.granted_query_memory,
       ER.executing_managed_code,
       ER.group_id,
       ER.query_hash,
       ER.query_plan_hash,
       ER.statement_sql_handle,
       ER.statement_context_id,
       ER.dop,
       ER.parallel_worker_count,
       ER.external_script_request_id,
       EQP.dbid,
       EQP.objectid,
       EQP.number,
       EQP.encrypted
FROM sys.dm_exec_requests AS ER
    CROSS APPLY sys.dm_exec_query_plan(ER.plan_handle) AS EQP
WHERE ER.session_id = <SPID>;

 

Dodaj komentarz