Seeing Procedure Execution Statistics in SQL Server

Hello to everyone,

In this article, I will try to give information about seeing Procedure Execution Statistics in SQL Server.

In SQL Server you may want to see Procedure Execution Statistics in some cases.

One advantage of Stored Procedures is that performance can be tracked. There may be many Stored Procedures in our database or SQL Server. You may want to see information such as how long they work, their working time, how much resources they use. This information shows us the information from the last run time of SQL Server to the time of writing the query. This information is kept in Memory and Cache. This information is lost when a restart is performed on SQL Server, but it is easy and useful to log the working information of historical Stored Procedures.

You can easily do this using the code below.

SELECT database_id,
       OBJECT_NAME(object_id, database_id) AS 'Prosedür Adı',
       (total_elapsed_time / execution_count) AS 'AVG Elapsed Time',
FROM sys.dm_exec_procedure_stats
WHERE database_id = DB_ID('AdventureWorks');

When you run the above code, you will see a result similar to the one below.

Seeing Procedure Execution Statistics in SQL Server

As you can see, we have seen the Procedure Execution Statistics.

Stored Procedure name, last run time, time elapsed when the procedure was run, how many times the procedure ran, etc. We were able to access information such as and show it in tabular form.

Good luck to everyone in business and life.


Yavuz Selim Kart

I try to explain what I know in software and database. I am still improving myself by doing research on many programming languages. Apart from these, I am also interested in Graphic Design and Wordpress. I also have knowledge about SEO and Social media management. In short, I am a determined person who likes to work hard.

You may also like...

Don`t copy text!