How do I find what is the associated query that is being executed if I have the SPID. Trying to figure out what query is being associated since the process seems to be hung.
what version of sql server? for 2000 and up you can do
dbcc inputbuffer (spid)
That will give the first 255 characters
replace spid with the numerical number for spid
for 2005 and up, change @@SPID to the spid you are looking for
select dest.*
from sys.dm_exec_requests as der
cross apply sys.dm_exec_sql_text (der.sql_handle) as dest
where session_id = @@spid