Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3847566
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T16:34:17+00:00 2026-05-19T16:34:17+00:00

We have a number of Views, Stored Procs, Table Values and Scalar functions. How

  • 0

We have a number of Views, Stored Procs, Table Values and Scalar functions.

How can we see how often or even how many times these have been called from within SQL Server?

Do we need to edit each one to update a table on each call to get this, or does SQL server keep this information somewhere?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T16:34:18+00:00Added an answer on May 19, 2026 at 4:34 pm

    This is one of Glenn Berry’s DMV queries. It counts how many times a cached stored procedure has been executed (filtered by the current database):

    SELECT TOP(25) p.name AS [SP Name], qs.execution_count,
    ISNULL(qs.execution_count/DATEDIFF(Second, qs.cached_time, GETDATE()), 0) AS [Calls/Second],
    qs.total_worker_time/qs.execution_count AS [AvgWorkerTime], qs.total_worker_time AS [TotalWorkerTime],  
    qs.total_elapsed_time, qs.total_elapsed_time/qs.execution_count AS [avg_elapsed_time],
    qs.cached_time
    FROM sys.procedures AS p
    INNER JOIN sys.dm_exec_procedure_stats AS qs
    ON p.[object_id] = qs.[object_id]
    WHERE qs.database_id = DB_ID()
    ORDER BY qs.execution_count DESC OPTION (RECOMPILE);
    

    Note: SQL Server keeps info only since last service restart and may also discard info under memory pressure.

    Also note that execution count alone does not tell the whole picture. It’s often better to identify the most costly queries and improve them. I usually start with highest logical reads (this is another of Glenn’s):

    SELECT TOP(25) p.name AS [SP Name], qs.total_logical_reads AS [TotalLogicalReads], 
    qs.total_logical_reads/qs.execution_count AS [AvgLogicalReads],qs.execution_count, 
    ISNULL(qs.execution_count/DATEDIFF(Second, qs.cached_time, GETDATE()), 0) AS [Calls/Second], 
    qs.total_elapsed_time, qs.total_elapsed_time/qs.execution_count 
    AS [avg_elapsed_time], qs.cached_time
    FROM sys.procedures AS p
    INNER JOIN sys.dm_exec_procedure_stats AS qs
    ON p.[object_id] = qs.[object_id]
    WHERE qs.database_id = DB_ID()
    ORDER BY qs.total_logical_reads DESC OPTION (RECOMPILE);
    

    [Also, note: you might have processes that are periodically scheduled (say once per month). So, it’s not 100% possible to identify stored procedures that are not called using these.]

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a number of manually written scripts (.sql) for tables, views and stored
I have created custom cell in which there are n number of image views.
I have a very large script which is creating multiple views. In a number
I have a number of .js files that I would like to be stored
Seeking general advice. I have an arbitrary number of UIImages s with references stored
I've learned that views can be used to create custom table views (so to
I have a lotus view that stores a number. I need to perform some
I have code similar to: number_to_currency(line_item.price, :unit => £) littering my views in various
I have a View where I draw a number of lines which may change
I have an view in my App which has a number of buttons based

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.