TSQL Script to fetch the code that is executed by an SPID

Posted on : 11-05-2012 | By : Devi Prasad | In : T-SQL Code Examples

Share:

0


Below is the TSQL Script to fetch the code that is executed by an SPID

[sql]
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)
[/sql]




References : Devi Prasad (sqlserverlearner.com)

Need Help On SQL Server?

Cannot Find Solution to your problem (or) If you are looking for some help on SQL Server. Dont worry Click Here to Post your question and solve your issue.


Do you like my blog?

If you liked reading this blog, please help spread the word by sharing this blog with your friends.




Write a comment