Tracking Currently Running Queries and Requests

The sys.dm_exec_requests view provides information about currently executing requests (queries or commands). Each row represents a single query or command being executed by a session.


Key Columns:

  • session_id: The ID of the session making the request.
  • request_id: A unique identifier for the request within a session.
  • database_id: The ID of the database being accessed by the request.
  • blocking_session_id: The ID of the session that is blocking the current request (if any).
  • command: The current command being executed (e.g., SELECT, INSERT).
  • wait_type: If the request is waiting, this column shows the type of wait (e.g., lock, I/O).
  • start_time: The time the request started execution.


Use Case:

sys.dm_exec_requests is useful for monitoring active queries or requests, identifying blocking sessions, and analyzing long-running queries.


Example Query:

SELECT session_id, request_id, database_id, blocking_session_id, command, start_time
FROM sys.dm_exec_requests;