tags:

views:

248

answers:

5

Is it possible to check is there any stored proc currently running in SQL Server???

A: 

There's the activity monitor in management studio. There's also sp_who and sp_who2. These will give you an idea of what is running.

However, if you need to programatically find out if a procedure is "in progress" or not to avoid calling it again then I'd consider a flag somewhere to indicate "SPIsRunning" that you set at the start and end of the procedure itself.

Robin Day
A: 

Via TSQL you could try evaluating the results of DBCC INPUTBUFFER for each SPID, but it's pretty cumbersome to do.

CodeByMoonlight
A: 
SELECT deqs.last_execution_time AS [Time], dest.TEXT AS [Query]
    FROM sys.dm_exec_query_stats AS deqs
            CROSS APPLY sys.dm_exec_sql_text(deqs.sql_handle) AS dest
    WHERE dest.TEXT LIKE '%YOUR OBJECT NAME HERE%'    
ORDER BY deqs.last_execution_time DESC


http://connectsql.blogspot.com/

this is a nice query, but only tells you the last time the procedure started, not if it is still running
KM
A: 

If you just want to see activity use SQL Profiler tracing Stored Procedures starting & completed. Maybe that helps you.