You are on page 1of 1

Frequently Ran Stored Procedure from Server Cache

Here is the script which will list frequently running stored procedure on your
entire server.

SELECT
DB_NAME(qt.[dbid]) AS 'DatabaseName',
OBJECT_SCHEMA_NAME(qt.[objectid], qt.[dbid]) AS 'SchemaName',
OBJECT_NAME(qt.[objectid], qt.[dbid]) AS 'SPName',
qs.execution_count AS 'Execution Count',
qs.total_worker_time/qs.execution_count AS 'AvgWorkerTime',
qs.total_worker_time AS 'TotalWorkerTime',
qs.total_logical_reads AS 'TotalLogicalReads',
qs.execution_count/DATEDIFF(Second, qs.creation_time, GETDATE()) AS 'Calls/Second',
qs.creation_time 'CreationTime'
FROM sys.dm_exec_query_stats AS qs
CROSS APPLY sys.dm_exec_sql_text(qs.sql_handle) AS qt
WHERE DB_NAME(qt.[dbid]) IS NOT NULL --remove to see all queries
ORDER BY qs.total_logical_reads DESC
Remember above query retrieves data from the server cache. If you have restarted
your server recently or your cache was removed/invalidated in the near past, you
should let your server run for a considerable amount of time before you make the
decision based on the data.

If you have a similar script, I request you to post in the comments section and I
will publish it with due credit to you.

You might also like