Saturday, June 9, 2018

SQL Currently running queries

Execute below query to find currently running queries in SQL.

This can be helpful to identify blocking.

      cast(axsess.context_info AS VARCHAR(128)) AS [Connection info],
      ,req.total_elapsed_time / 1000.0 AS total_elapsed_time
   ,DB_NAME(req.database_id) AS DB_NAME     
 FROM  sys.dm_exec_requests req
 CROSS APPLY sys.dm_exec_sql_text(sql_handle) AS sqltext
 JOIN  sys.dm_exec_sessions ses
     ON ses.session_id = req.session_id
  ---cast(axsess.context_info AS VARCHAR(128)) AS [Connection info] , *
  sys.dm_exec_sessions axsess
 on axsess.session_id = req.session_id
 where DB_NAME(req.database_id) = db_name()
 --axsess.program_name LIKE '%Dynamics%'
 --and axsess.status = 'running' 
 --and req.wait_type IS NOT NULL
 --and req.wait_type = 'OLEDB'     

No comments:

Post a Comment

ADFS configuration error Invalid scope names

I am about to finish On-Prem deployment, where i was facing error at   step number 18     as below: "ADFS configuration for premises ...