gd qry to identify running query inside sp without profiler

1 view
Skip to first unread message

ranjan...@thomsonreuters.com

unread,
Feb 14, 2013, 2:27:01 AM2/14/13
to Pramod.J...@indecomm.net, mus...@planwell.com, balachandra...@genpact.com, rkali...@gmail.com, dwhte...@googlegroups.com

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

 

Mushir

unread,
Feb 14, 2013, 2:43:04 AM2/14/13
to ranjan...@thomsonreuters.com, Pramod.J...@indecomm.net, balachandra...@genpact.com, rkali...@gmail.com, dwhte...@googlegroups.com

Good one !

DBCC INPUTBUFFER(65) would give you all the statements from the same process but would not be able to identify what exactly is running at the moment.

Reply all
Reply to author
Forward
0 new messages