?
Solved

View currently running queries on SQL Server 2005?

Posted on 2007-11-27
4
Medium Priority
?
2,964 Views
Last Modified: 2012-06-27
What are the options/methods available for one who wishes to see the actual queries running and who is running them.  I know how to use sp_who2 if I want to see who is logged in, but I want to see the actual queries.
0
Comment
Question by:donnatronious
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 3

Accepted Solution

by:
bcaff86 earned 2000 total points
ID: 20360652
Without using 3rd party tools your best bet is to use SQL Profiler and run a trace.  If you are in Mgmt Studio - go to Tools->SQL Profiler.  You can set a ton of options in there but essentially you want to see batches starting and completing.

You can also use dbcc inputbuffer(spid) where spid is the spid from your sp_who command.  It will tell you the last command on the spid.  

Typically I find a trace to be more useful though.
0
 
LVL 16

Expert Comment

by:SQL_SERVER_DBA
ID: 20360758
SELECT * FROM MASTER..SYSPROCESSES
0
 
LVL 18

Expert Comment

by:Yveau
ID: 20361313
Run a trace using the SQL Profiler, and you can see the SQL that is being fired against your SQL Server ...

Hope this helps ...
0
 
LVL 18

Expert Comment

by:Yveau
ID: 20361519
To soon with the points ...
run this query:

SELECT
st.text
FROM
sys.dm_exec_requests r
CROSS APPLY
sys.dm_exec_sql_text(sql_handle) AS st
WHERE r.session_id = <spid number>

Hope this helps ...
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

by Mark Wills PIVOT is a great facility and solves many an EAV (Entity - Attribute - Value) type transformation where we need the information held as data within a column to become columns in their own right. Now, in some cases that is relatively…
In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question