November 4, 2009 at 5:49 am
Is there anyway i can find out currently running stored procedure name ?
November 4, 2009 at 7:24 am
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
November 4, 2009 at 7:35 am
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'
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply