Shaded
Shaded

Reputation: 17876

See queries that hit SQL

Is there a way using sql 2008 Management Studio to look at the queries that hit the server? I'm trying to debug a program and I get messages like "Incorrect syntax near the keyword 'AND'". Since the queries are being dynamically generated it's a hassle to figure out what is going to the server.

Any help is appreciated!

Upvotes: 4

Views: 2236

Answers (6)

Chris R. Timmons
Chris R. Timmons

Reputation: 2207

One option is to use SQL Server Profiler to run a trace. However, in some shops SQL Server permissions are set so only DBAs can run traces.

If you don't have sufficient rights to run a trace, then another option is to view the network traffic between the application that generates the SQL and box SQL Server is running on. WireShark works great for that.

Upvotes: 0

SQLMenace
SQLMenace

Reputation: 135151

start up profiler from SSMS (Tools-->SQL Server Profiler), run a trace and select the T-SQL events

Upvotes: 0

Neil N
Neil N

Reputation: 25278

Since the queries are being dynamically generated it's a hassle to figure out what is going to the server.

Why not just put the query that's generated into a message box, or print it to the console, or webpage, etc. ??

Trying to catch it at the DB server seems to be the long-way-around to debugging some simple ad-hoc queries.

Upvotes: 2

Mike M.
Mike M.

Reputation: 12541

There is a tool called Profiler that will tell you all information that you'll need. MSDN: http://msdn.microsoft.com/en-us/library/ms187929.aspx

Upvotes: 6

Neil N
Neil N

Reputation: 25278

Go to Management...Activity Monitor in the object explorer.

It's not live though, you will have to refresh it manually.

Upvotes: 1

Aaronaught
Aaronaught

Reputation: 122674

I'm not aware of any method to do this using SQL Server Management Studio, but if you installed SSMS then you probably also installed the SQL Profiler. If you fire that up and run the TSQL_SPs profiler template, you can see every statement that's hitting the database.

Upvotes: 2

Related Questions