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 86599
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T22:16:17+00:00 2026-05-10T22:16:17+00:00

It’s a trivial task to find out if an object is referenced by something

  • 0

It’s a trivial task to find out if an object is referenced by something else or not. What I’d like to do is identify whether or not it’s actually being used.

My solution originally involved a combination of a table that held a list of objects in the database and an hourly job.

The job did two things. First, it looked for new objects that had been added to the database since the last run. Secondly, it looked at sql’s object cache. If an object in the table was listed in the cache, it was marked off in the table as having been recently ‘seen’ in use.

At the end of a six month period or whatever, the contents of the table were examined. Anything listed in the table that hadn’t been seen referenced since I started monitoring were probably safe to backup and remove.

Sure, there is the possibility of objects that are only used, say, once a year or whatever, but it seemed to work for the most part.

It was kind of a pain to work with, though.

There are about a half dozen databases I’m working with, the majority of which have tons of legacy tables on them, which remain long after their original creators moved on to other companies.

What I’m looking for is a fairly reliable method of keeping track of when an object (table, view, stored procedure, or function) is getting called.

For those of you who currently monitor this sort of thing, what method/code do you use and would you recommend it?

  • 1 1 Answer
  • 1 View
  • 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. 2026-05-10T22:16:18+00:00Added an answer on May 10, 2026 at 10:16 pm

    With SQL Server 2005, you can use the dynamic management view sys.dm_db_index_usage_stats. The name says ‘index’ but that’s a little misleading – every table has an entry in here, even if it doesn’t have any indexes. Here’s a useful query from SQL Magazine:

    SELECT    t.name AS 'Table',    SUM(i.user_seeks + i.user_scans + i.user_lookups)      AS 'Total accesses',   SUM(i.user_seeks) AS 'Seeks',   SUM(i.user_scans) AS 'Scans',   SUM(i.user_lookups) AS 'Lookups' FROM    sys.dm_db_index_usage_stats i RIGHT OUTER JOIN      sys.tables t ON (t.object_id = i.object_id) GROUP BY    i.object_id,    t.name ORDER BY [Total accesses] DESC 

    Here’s the original article:

    http://www.sqlmag.com/Article/ArticleID/53878/sql_server_53878.html

    Keep in mind that these usage statistics reset when SQL Server restarts.

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I would like to count the length of a string with PHP. The string
For some reason, after submitting a string like this Jack’s Spindle from a text
I've got a string that has curly quotes in it. I'd like to replace
I am trying to render a haml file in a javascript response like so:
I would like to run a str_replace or preg_replace which looks for certain words
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I know there's a lot of other questions out there that deal with this
Seemingly simple, but I cannot find anything relevant on the web. What is the

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.