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 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
  • 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. 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

Ask A Question

Stats

  • Questions 123k
  • Answers 123k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer That's not a lot of information, so this answer is… May 12, 2026 at 12:59 am
  • Editorial Team
    Editorial Team added an answer In the past I have successfully used Unison File Synchronizer.… May 12, 2026 at 12:59 am
  • Editorial Team
    Editorial Team added an answer You cannot set TargetProperty in Style Trigger. This basically means… May 12, 2026 at 12:59 am

Related Questions

Is it possible to replace javascript w/ HTML if JavaScript is not enabled on
I am currently running into a problem where an element is coming back from
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
Seemingly simple, but I cannot find anything relevant on the web. What is the
It seems to me obfuscation is an idea that falls somewhere in the security

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.