Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any tool to see the queries run against the database?

Is there any tool that will inspect either asp.net or sql server and report all the queries that are run against the database? The reason I ask is I am using Linq for a project and want to double check what its actually doing for each page.

Ideally I'd like to view a page in a browser and have a report of all the queries that were run to create that page.

I know I can view the SQL it runs for individual queries using debugging/breakpoints, and I know about LinqPad, but I'm afraid Linq is making several more queries on its own to get related data that I may not be directly aware of. Is there anything (tool/program/report/etc) like what I described? Thanks!

EDIT: Is there any FREE tool that can do this? I am using Sql Server 2008 Express and don't have SQL Profiler unfortunately.

like image 437
Ryan Avatar asked Jul 29 '09 17:07

Ryan


People also ask

Can I see historical queries run on a SQL Server database?

The SQL Query History window allows you to view, search, edit the executed queries. To open the window, point to Other Windows in the View menu, and then click SQL Query History.


2 Answers

Absolutely, There is a SQL tool called SQL Profiler. It does require elevated database permissions in order to run profiler.

There is a decent tutorial on how to run Profiler on TechRepublic.

Another option out there is the NHibernate Profiler. I know that it is not as "free" as SQL Profiler, have never used it, but the screen shots for it look pretty cool.

like image 151
RSolberg Avatar answered Oct 25 '22 13:10

RSolberg


Profiler is the best tool of them all for this but it can be expensive in inexperienced hands.

You can also try to do "exec sp_who" and then a "dbcc inputbuffer (111)" - just put the process id in the place of 111.

like image 38
Raj More Avatar answered Oct 25 '22 13:10

Raj More