Pages

Tuesday, February 8, 2011

To find the queries running in the current session

To find the queries running in the current session


the below query we have to give the spid dynamically

DECLARE @sqltext VARBINARY(128) SELECT @sqltext = sql_handle FROM sys.sysprocessesWHERE spid = (60) SELECT TEXTFROM sys.dm_exec_sql_text(@sqltext) GO


OR we can use the other method


dbcc inputbuffer(spid)


OR we can use the other method


SELECT TEXT FROM sys.dm_exec_connections CROSS APPLY sys.dm_exec_sql_text(most_recent_sql_handle) WHERE session_id = (yoursessionID) GO

Hope the above query helps

Thanks