Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

sys.processes? how to query the commands as well? Expand / Collapse
Author
Message
Posted Monday, May 14, 2007 8:11 AM
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Thursday, April 28, 2011 9:16 AM
Points: 345, Visits: 228
i know i could always check the management studio activity, but
wondering if there was a way i can see the commands behind this
maybe with another query?




_________________________
Post #365627
Posted Monday, May 14, 2007 8:24 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Tuesday, October 04, 2011 10:05 AM
Points: 11, Visits: 30

In sql 2000, I used

   SELECT @SQL = text
   FROM   ::fn_get_sql(@Handle)

where @Handle is the sql_handle from sysprocesses.

That seems to still work on 2005.




Post #365640
Posted Tuesday, May 15, 2007 6:29 AM
SSCarpal Tunnel

SSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal Tunnel

Group: General Forum Members
Last Login: Today @ 10:19 AM
Points: 4,505, Visits: 9,197
or there is also dbcc inputbuffer(spid)

---------------------------------------------------------------------

proud member of the 'et al' fraternity.
Post #365921
Posted Tuesday, May 15, 2007 7:07 AM
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Thursday, April 28, 2011 9:16 AM
Points: 345, Visits: 228
dbcc inputbuffer(spid) sounds easy to me.


_________________________
Post #365933
Posted Tuesday, May 15, 2007 7:58 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Tuesday, October 04, 2011 10:05 AM
Points: 11, Visits: 30

I did a little research myself, as I was looking for something like it as well.
To get the currently running processes, use:

SELECT
session_id,status,
command,sql_handle,database_id
,(SELECT text FROM sys.dm_exec_sql_text(sql_handle)) AS query_text
FROM sys.dm_exec_requests r
WHERE session_id >= 51

For more detail about was has been running, try:

select s.session_id, s.login_name, s.host_name, s.status,
s.program_name, s.cpu_time, s.last_request_start_time,
(
SELECT text FROM sys.dm_exec_sql_text(c.most_recent_sql_handle)) AS query_text
from sys.dm_exec_sessions s, sys.dm_exec_connections c
where s.session_id = c.session_id and
s.session_id > 50
order by s.last_request_start_time desc

 




Post #365968
Posted Tuesday, May 15, 2007 8:16 AM
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Thursday, April 28, 2011 9:16 AM
Points: 345, Visits: 228
now that is EXACTLY what i was looking for.

excellent work!

thanks!



_________________________
Post #365983
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse