Currently running query inside a stored procedure

后端 未结 3 492
长情又很酷
长情又很酷 2020-12-31 10:01

I have a stored procedure that is currently running, and seems to hang/lock on a specific query. How can i see which query? Preferably without modifying the proc.

Us

相关标签:
3条回答
  • 2020-12-31 10:15

    There is an excellent stored procedure to get extended information on currently running queries. It's available to download from: http://whoisactive.com

    0 讨论(0)
  • 2020-12-31 10:23
    SELECT SUBSTRING(st.text, ( r.statement_start_offset / 2 ) + 1, 
                  ( ( CASE WHEN r.statement_end_offset <= 0
                           THEN DATALENGTH(st.text) 
                  ELSE r.statement_end_offset END - 
           r.statement_start_offset ) / 2 ) + 1) AS statement_text 
    FROM   sys.dm_exec_requests r 
           CROSS APPLY sys.dm_exec_sql_text(sql_handle) st 
    WHERE  session_id = 65 
    
    0 讨论(0)
  • 2020-12-31 10:34

    Use SQL Profiler; as the name suggests, it's the main profiling tool for SQL Server and it can show the execution time for each statement inside a procedure.

    0 讨论(0)
提交回复
热议问题