Wednesday, November 3, 2010

Query to get retreive a query in a session

DECLARE @sqltext VARBINARY(128)
SELECT @sqltext = sql_handle
FROM sys.sysprocesses
WHERE spid = (sessionid)
print @sqltext
SELECT TEXT
FROM sys.dm_exec_sql_text(@sqltext)
GO

No comments:

Post a Comment