CluelessDev
CluelessDev

Reputation:

Sniffing queries to SQL Server

Is there a way to sniff SQL queries sent to a SQL Server db on any level (above transport level)? Perhaps there's some kind of a tracer in ASP.NET or built-in log in SQL Server ?

Upvotes: 8

Views: 14149

Answers (3)

Dave Harding
Dave Harding

Reputation: 1390

When you are in SQL Management Studio, open the query editor and set it to the correct database you would like to profile. Run the following query:

select db_id()

That will tell you your database id .

  • Go to Tools > SQL Profile Manager.
  • Click file > New trace ...
  • Connect to your database server.
  • On the window that shows up, click on the Events Selection tab.
  • Click the Show All Columns checkbox.
  • Then click Column Filters and choose DatabaseID in the Edit Filter box.

    On the right, choose "Equals" and put in the database id from the query above.

  • Click OK and then Run.

Upvotes: 5

Nick Kavadias
Nick Kavadias

Reputation: 7368

The tool your looking for is SQL Server Profiler, learn to use it and to love it.

Try starting with a filter on ApplicationName and/or HostName for your IIS server running your ASP.NET application. Profiler can get quite chatty.

Upvotes: 4

JSC
JSC

Reputation: 3725

SQL Server Profiler perhaps? This will pick up what queries are executed. You can also get statistics, query plans and many other items of interest from this.

Upvotes: 11

Related Questions