Solved

View currently running queries on SQL Server 2005?

Posted on 2007-11-27
4
2,958 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
  • 2
4 Comments
 
LVL 3

Accepted Solution

by:
bcaff86 earned 500 total points
Comment Utility
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
Comment Utility
SELECT * FROM MASTER..SYSPROCESSES
0
 
LVL 18

Expert Comment

by:Yveau
Comment Utility
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
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
combine data in sql 1 28
Dataset not reading table data 12 41
SQL Select * from 6 29
sql Audit table 3 47
There are some very powerful Data Management Views (DMV's) introduced with SQL 2005. The two in particular that we are going to discuss are sys.dm_db_index_usage_stats and sys.dm_db_index_operational_stats.   Recently, I was involved in a discu…
by Mark Wills Attending one of Rob Farley's seminars the other day, I heard the phrase "The Accidental DBA" and fell in love with it. It got me thinking about the plight of the newcomer to SQL Server...  So if you are the accidental DBA, or, simp…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

772 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now