Search

Thursday, October 11, 2012

Script to fetch the code that is executed by an SPID

Use below TSQL Script to fetch the code that is executed by a SPID:


DECLARE @sql_handle AS VARBINARY (1000)

SELECT @sql_handle = SQL_HANDLE
FROM   sys.sysprocesses WITH (NOLOCK)
WHERE  spid = 56; --To Do: Update with SPID OF the Process
  
SELECT * 
FROM   sys.dm_exec_sql_text (@sql_handle)

No comments:

Post a Comment