Kalyan Kumar Akula's Blog : This Blog is about SQL Server
Thursday, August 2, 2012
Get SQL Query from SPID
SELECT sp.spid, sp.blocked, sp.loginame, sp.last_batch, sp.status, sp.hostname, sp.program_name,
(SELECT text FROM sys.dm_exec_sql_text(sp.sql_handle)) AS 'Query'
FROM SysProcesses sp LEft OUTER JOIN sysdatabases sd
on sp.spid = sd.dbid
No comments: