SQL: How can I get the number of database queries completed or an hour or ...?

Is there a way to see how many queries are executed every hour, and for each database / hour or the average number of queries per day, or ... what's interesting?

Just for statistics .. I like the numbers. I can’t just start tracing with Sql Server Profiler, because the user interface will crash when too many requests appear.

Does SQL somewhere keep track of some basic statistics about executed queries or any tools that I can use to get this information?

(I am using SQL Server 2008 R2)

+7
source share
2 answers

This should work:

select * from sys.dm_os_performance_counters where counter_name = 'Batch Requests/sec' 

It actually returns full packet requests. You periodically check this number, and then use this calculation:

 ReqsPerSec = (curr.Value - prev.Value) / (curr.time - prev.time) 
+5
source

I really find out about this in my Microsoft Certification.

Although I cannot answer your question directly, I can send you in the right direction with a few things:

  • Look at the views inside the server> Databases> System Databases> MSDB> Views> System Views. Systsem MSDN Views
  • Look at the views inside the server> Databases> System Databases> Wizard> Views> System Views.
  • Take the peak of the trace tools available for SQL Server.

In the views, note that you may actually need to join several views together or get in the base tables to get what you need.

0
source

All Articles