|
|
|
SSC-Enthusiastic
      
Group: General Forum Members
Last Login: Tuesday, May 07, 2013 4:03 PM
Points: 132,
Visits: 152
|
|
Is there anyway i can find out currently running stored procedure name ?
|
|
|
|
|
SSChampion
        
Group: General Forum Members
Last Login: Today @ 7:02 AM
Points: 11,791,
Visits: 28,069
|
|
not sure what you mean...inside a TSQL code block, you could use
print object_name(@@PROCID)
or do you mean show me all the sql statements that are currently running on the server, like from one of the DMV's?
SELECT DEST.TEXT FROM sys.[dm_exec_connections] SDEC CROSS APPLY sys.[dm_exec_sql_text](SDEC.[most_recent_sql_handle]) AS DEST --WHERE SDEC.[most_recent_session_id] = @spid
Lowell
--There is no spoon, and there's no default ORDER BY in sql server either. Actually, Common Sense is so rare, it should be considered a Superpower. --my son
|
|
|
|
|
Mr or Mrs. 500
      
Group: General Forum Members
Last Login: 2 days ago @ 8:33 AM
Points: 531,
Visits: 419
|
|
Try this: SELECT r.*,t.text FROM sys.dm_exec_requests r cross apply sys.dm_exec_sql_text(r.sql_handle) t WHERE r.status IN (N'Suspended',N'Running',N'Runnable',N'Pending')
The text column is the code of the procedure/batch that is currently running in SQL Server
If all your SPs finish every quickly, the query may not be able to catch anything.
You can try the following in a separate window then run the above query, you will catch it
select * from master.dbo.spt_values WAITFOR DELAY N'00:30:00'
|
|
|
|