简体   繁体   中英

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 ?

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.

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM