Friday, October 26, 2012

0 How to find out what SQL is currently running by particular session ?

There are at least 2 ways to find out what SQL is running by particular session. DBCC INPUTBUFFER and DMV.

DBCC INPUTBUFFER( Session ID)

Use sp_who to find the session ID. Then run

DBCC INPUTBUFFER(148)

image

DMV

Find the SQL Handle

Select session_id,status,command,sql_handle,database_id
from sys.dm_exec_requests;

image

select session_id,txt from sys.dm_exec_requests r cross_apply sys.dm_exec_sql_text( HANDLE) 
where session_id = id;
 
image

image

0 comments:

Post a Comment

 

SQL Panda Copyright © 2011 - |- Template created by O Pregador - |- Powered by Blogger Templates