Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

currently running stored procedure name Expand / Collapse
Author
Message
Posted Wednesday, November 4, 2009 5:49 AM


SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Saturday, November 8, 2014 5:05 AM
Points: 132, Visits: 165
Is there anyway i can find out currently running stored procedure name ?


Post #813548
Posted Wednesday, November 4, 2009 7:24 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Yesterday @ 10:20 AM
Points: 12,927, Visits: 32,332
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
Post #813581
Posted Wednesday, November 4, 2009 7:35 AM
Mr or Mrs. 500

Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500

Group: General Forum Members
Last Login: Wednesday, October 22, 2014 7:18 AM
Points: 531, Visits: 433
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'



Post #813586
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse