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

  • Home
  • SEARCH
  • 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 7878343
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T03:37:56+00:00 2026-06-03T03:37:56+00:00

I am trying to track down all stored procedures in a database that have

  • 0

I am trying to track down all stored procedures in a database that have never been used, or that have not been used in many months.

I would like to find a query to show all the stored procedures that are not in use so that those stored procedures can be analyzed to determine if they can be removed.

I am familiar with sys.procedures, but don’t know how to determine if a procedure is in use or not.

SELECT *
FROM sys.procedures;

Using SQL Server 2008 R2.

UPDATE UPDATE UPDATE

Using the query from Aaron Bertrand below, slightly modified, this is what I ended up using, and it was perfect.

SELECT p.*
  FROM sys.procedures AS p
  LEFT JOIN sys.dm_exec_procedure_stats AS s ON s.[object_id] = p.[object_id]
 WHERE s.object_id IS NULL;

Thanks for the hlep.

  • 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-06-03T03:37:57+00:00Added an answer on June 3, 2026 at 3:37 am

    DMVs will record stats for procedures, but they only possibly go as far back as the last restart (and often not that far, depending on how long a plan lives in cache):

    SELECT * FROM sys.dm_exec_procedure_stats AS s
    INNER JOIN sys.procedures AS p
    ON s.[object_id] = p.[object_id]
    ORDER BY p.name;
    

    So if your system has only been up for a short time, this is not a reliable measure. The link @Siva points out is useful as well for some other ideas. Unfortunately SQL Server doesn’t really track this for you overall so unless you add tracing or logging you are stuck with the trust you place in the DMV…

    EDIT it was a good point, I was solving for the procedures that have run. Instead you may want this:

    SELECT sc.name, p.name 
    FROM sys.procedures AS p
    INNER JOIN sys.schemas AS sc
      ON p.[schema_id] = sc.[schema_id]
    LEFT OUTER JOIN sys.dm_exec_procedure_stats AS st
      ON p.[object_id] = st.[object_id]
    WHERE st.[object_id] IS NULL
    ORDER BY p.name;
    

    Or you may want to also include procedures that have run as well, but order them by when they last ran:

    SELECT sc.name, p.name 
    FROM sys.procedures AS p
    INNER JOIN sys.schemas AS sc
      ON p.[schema_id] = sc.[schema_id]
    LEFT OUTER JOIN sys.dm_exec_procedure_stats AS st
    ON p.[object_id] = st.[object_id]
    ORDER BY st.last_execution_time, p.name;
    

    This will order first the procedures that haven’t run since a restart, then the rest by when they were executed last, oldest first.

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

Sidebar

Related Questions

This is a problem I have been trying to track down for a couple
I have been trying to track down a problem with a query I have.
I have been trying to track down weird problems with my mod_wsgi/Python web application.
I'm trying to track down an issue in our MFC code that looks like
I'm trying to track down a bug that occurs when I click a particular
I've been trying to track down why Spring Security isn't creating the Spring Security
I'm trying to track down a problem in a (C++) Windows application that occurs
I am trying to track down why a string is stored so long in
I've been trying to track this down for a while but I'm at a
I've been trying to track down an intermittent crashing bug in my code (which

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.