Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Identifying Unused Objects in a Database


Identifying Unused Objects in a Database

Author
Message
SuperDBA-207096
SuperDBA-207096
SSCommitted
SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)

Group: General Forum Members
Points: 1583 Visits: 711

Right.. I guess you'd have to look real close at each object and make really sure it's not being used. It could point you in the right direction I guesss... You could identify for sure that an object is used, but not be 100% certain an object isn't used...


Leo Peysakhovich
Leo Peysakhovich
SSC-Enthusiastic
SSC-Enthusiastic (185 reputation)SSC-Enthusiastic (185 reputation)SSC-Enthusiastic (185 reputation)SSC-Enthusiastic (185 reputation)SSC-Enthusiastic (185 reputation)SSC-Enthusiastic (185 reputation)SSC-Enthusiastic (185 reputation)SSC-Enthusiastic (185 reputation)

Group: General Forum Members
Points: 185 Visits: 341

Thanks, that you get attention to my wording (not many people captured it)

There are several tricks. When you define the suspicious objects that may not be used, you can add simple trigger for select, insert, update with simple insert to log table with info about the table beeng accessed, date, and user. In addition, I am lucky because we adapt the policy and management supporting me with it that all calls (even simple reports with 1 SQL statement) only by stored procedures.

)



Frances L
Frances L
Old Hand
Old Hand (373 reputation)Old Hand (373 reputation)Old Hand (373 reputation)Old Hand (373 reputation)Old Hand (373 reputation)Old Hand (373 reputation)Old Hand (373 reputation)Old Hand (373 reputation)

Group: General Forum Members
Points: 373 Visits: 299
Yesterday I run

select bucketid, cacheobjtype, objtype, objid, dbid
from master.dbo.SYSCACHEOBJECTS
where objid = 1718297181

at 10:30 am.

I do not understand why it keep lock the other process.


Frances L
Frances L
Old Hand
Old Hand (373 reputation)Old Hand (373 reputation)Old Hand (373 reputation)Old Hand (373 reputation)Old Hand (373 reputation)Old Hand (373 reputation)Old Hand (373 reputation)Old Hand (373 reputation)

Group: General Forum Members
Points: 373 Visits: 299

I do not understand I run the process

select bucketid, cacheobjtype, objtype, objid, dbid
from master.dbo.SYSCACHEOBJECTS
where objid = 1718297181.

It still lock the process. My other scheduled task aplication in the server could not run due to the lock. Thanks.


Robert Davis
Robert Davis
SSCommitted
SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)

Group: General Forum Members
Points: 1916 Visits: 1623

Try running this instead:

select bucketid, cacheobjtype, objtype, objid, dbid
from master.dbo.SYSCACHEOBJECTS with(nolock)
where objid = 1718297181





My blog: SQL Soldier
Twitter: @SQLSoldier
My book: Pro SQL Server 2008 Mirroring
Microsoft Certified Master, SQL Server MVP
Database Engineer at BlueMountain Capital Management
Leo Peysakhovich
Leo Peysakhovich
SSC-Enthusiastic
SSC-Enthusiastic (185 reputation)SSC-Enthusiastic (185 reputation)SSC-Enthusiastic (185 reputation)SSC-Enthusiastic (185 reputation)SSC-Enthusiastic (185 reputation)SSC-Enthusiastic (185 reputation)SSC-Enthusiastic (185 reputation)SSC-Enthusiastic (185 reputation)

Group: General Forum Members
Points: 185 Visits: 341

Please try to read article carefully before trying.

#1. You can use "nolock" hint

#2. I did exclude where clause from the tests I was doing. Insert all rows to the temporary table and then get the objectid you are looking for. I show it for one object as an example at the beginning of the article. But in reality I never done it on the object by object bases.

Always all records from syscache table and then make an analysis





Kevin Fairchild-479614
Kevin Fairchild-479614
Forum Newbie
Forum Newbie (8 reputation)Forum Newbie (8 reputation)Forum Newbie (8 reputation)Forum Newbie (8 reputation)Forum Newbie (8 reputation)Forum Newbie (8 reputation)Forum Newbie (8 reputation)Forum Newbie (8 reputation)

Group: General Forum Members
Points: 8 Visits: 12
I did a slight alteration to the way this works in order to better do what I wanted... Rather than doing the insert each time and then relying on the query at the end to determine if it had been in the cache at one point, I insert up front and then have the job delete from the table any references to that object if it's currently in the cache. This way, whatever is in the table at the end of my monitoring period are things that weren't in the cache at some point during the period.

Granted, it isn't fool-proof going off the cache, but it at least helps narrow things down.

--Kevin Fairchild
Tim Brown-465757
Tim Brown-465757
SSC Rookie
SSC Rookie (25 reputation)SSC Rookie (25 reputation)SSC Rookie (25 reputation)SSC Rookie (25 reputation)SSC Rookie (25 reputation)SSC Rookie (25 reputation)SSC Rookie (25 reputation)SSC Rookie (25 reputation)

Group: General Forum Members
Points: 25 Visits: 144
Okay, this works for SS2005. What exists to do the same kind of thing in SS2000?
gfinzer
gfinzer
Forum Newbie
Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)

Group: General Forum Members
Points: 1 Visits: 1
I saw this tool that finds Unused Stored Procedures:
[url=http://www.kellermansoftware.com/p-35-unused-stored-procedures.aspx][/url]
BobMcC
BobMcC
SSC-Enthusiastic
SSC-Enthusiastic (190 reputation)SSC-Enthusiastic (190 reputation)SSC-Enthusiastic (190 reputation)SSC-Enthusiastic (190 reputation)SSC-Enthusiastic (190 reputation)SSC-Enthusiastic (190 reputation)SSC-Enthusiastic (190 reputation)SSC-Enthusiastic (190 reputation)

Group: General Forum Members
Points: 190 Visits: 757
Sorry to resurrect this old thread, but I"m in the middle of a project to upgrade our sql 2000 dbs to sql 2008. I'd like to also use this as an opportunity to get rid of any procedures that aren't being used.

For the most part, I like the solution. I'm curious to hear everyone's input though about the frequency he ran the update code. Every 15 minutes? Ouch! Can somoene explain to me why this couldn't just as easily be run every hour or every 3 or 4 hours. If I were to run that code on my dbs every 15 minutes for a month, and have a whole other issue to contend with!w00t
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search