How to extract corresponding query of sql_handle from sys.sysprocesses

Method 1

 

DECLARE @HANDLE BINARY(20)

SELECT @HANDLE = SQL_HANDLE FROM SYSPROCESSES WHERE SPID = 52

SELECT * FROM ::FN_GET_SQL(@HANDLE)

Method 2


Select * from sys.sysprocesses
cross apply sys.dm_exec_sql_text (sql_handle)

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s