﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / Discuss Content Posted by Leo Peysakhovich / Article Discussions / Article Discussions by Author  / Identifying Unused Objects in a Database / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Tue, 18 Jun 2013 15:12:16 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: Identifying Unused Objects in a Database</title><link>http://www.sqlservercentral.com/Forums/Topic304718-163-1.aspx</link><description>[quote][b]BobMcC (7/30/2009)[/b][hr]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:[/quote]There is no harm to output to stand along table with identity column primary key in another database every 15 minute.Even it will be millions of rows identity will always pack the rows and place it at the end of the page.  I did it for 2 months and run solution every 2-3 minutes without any issues.</description><pubDate>Sun, 02 Aug 2009 13:26:01 GMT</pubDate><dc:creator>Leo Peysakhovich</dc:creator></item><item><title>RE: Identifying Unused Objects in a Database</title><link>http://www.sqlservercentral.com/Forums/Topic304718-163-1.aspx</link><description>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:</description><pubDate>Thu, 30 Jul 2009 13:54:09 GMT</pubDate><dc:creator>BobMcC</dc:creator></item><item><title>RE: Identifying Unused Objects in a Database</title><link>http://www.sqlservercentral.com/Forums/Topic304718-163-1.aspx</link><description>I saw this tool that finds Unused Stored Procedures:[url=http://www.kellermansoftware.com/p-35-unused-stored-procedures.aspx][/url]</description><pubDate>Wed, 17 Sep 2008 09:15:56 GMT</pubDate><dc:creator>gfinzer</dc:creator></item><item><title>RE: Identifying Unused Objects in a Database</title><link>http://www.sqlservercentral.com/Forums/Topic304718-163-1.aspx</link><description>Okay, this works for SS2005.  What exists to do the same kind of thing in SS2000?</description><pubDate>Wed, 23 Jul 2008 10:47:56 GMT</pubDate><dc:creator>Tim Brown-465757</dc:creator></item><item><title>RE: Identifying Unused Objects in a Database</title><link>http://www.sqlservercentral.com/Forums/Topic304718-163-1.aspx</link><description>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</description><pubDate>Tue, 11 Sep 2007 09:28:00 GMT</pubDate><dc:creator>Kevin Fairchild-479614</dc:creator></item><item><title>RE: Identifying Unused Objects in a Database</title><link>http://www.sqlservercentral.com/Forums/Topic304718-163-1.aspx</link><description>&lt;P&gt;Please try to read article carefully before trying.&lt;/P&gt;&lt;P&gt;#1. You can use "nolock" hint&lt;/P&gt;&lt;P&gt;#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. &lt;/P&gt;&lt;P&gt;Always all records from syscache table and then make an analysis&lt;/P&gt;</description><pubDate>Tue, 12 Sep 2006 16:07:00 GMT</pubDate><dc:creator>Leo Peysakhovich</dc:creator></item><item><title>RE: Identifying Unused Objects in a Database</title><link>http://www.sqlservercentral.com/Forums/Topic304718-163-1.aspx</link><description>&lt;P&gt;Try running this instead:&lt;/P&gt;&lt;P&gt;&lt;FONT color=#3333dd&gt;select bucketid, cacheobjtype, objtype, objid, dbid       from master.dbo.SYSCACHEOBJECTS with(nolock) where  objid = 1718297181&lt;/FONT&gt;&lt;/P&gt;</description><pubDate>Tue, 12 Sep 2006 11:37:00 GMT</pubDate><dc:creator>Robert Davis</dc:creator></item><item><title>RE: Identifying Unused Objects in a Database</title><link>http://www.sqlservercentral.com/Forums/Topic304718-163-1.aspx</link><description>&lt;P&gt;I do not understand I run the process&lt;/P&gt;&lt;P&gt;&lt;FONT color=#3333dd&gt;select bucketid, cacheobjtype, objtype, objid, dbid       from master.dbo.SYSCACHEOBJECTS where  objid = 1718297181.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color=#3333dd&gt;&lt;/FONT&gt; &lt;/P&gt;&lt;P&gt;&lt;FONT color=#3333dd&gt;It still lock the  process. My other scheduled task aplication in the server could not run due to the lock. Thanks.&lt;/FONT&gt;&lt;/P&gt;</description><pubDate>Tue, 12 Sep 2006 05:59:00 GMT</pubDate><dc:creator>Frances L</dc:creator></item><item><title>RE: Identifying Unused Objects in a Database</title><link>http://www.sqlservercentral.com/Forums/Topic304718-163-1.aspx</link><description>Yesterday I run &lt;P&gt;&lt;FONT color=#3333dd&gt;select bucketid, cacheobjtype, objtype, objid, dbid       from master.dbo.SYSCACHEOBJECTS where  objid = 1718297181&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color=#3333dd&gt;at 10:30 am.&lt;/P&gt;&lt;/FONT&gt;&lt;P&gt;&lt;FONT color=#3333dd&gt;I do not understand why it keep lock the other process.&lt;/P&gt;&lt;/FONT&gt;&lt;P&gt;&lt;FONT color=#3333dd&gt; &lt;/P&gt;&lt;/FONT&gt;</description><pubDate>Tue, 12 Sep 2006 05:53:00 GMT</pubDate><dc:creator>Frances L</dc:creator></item><item><title>RE: Identifying Unused Objects in a Database</title><link>http://www.sqlservercentral.com/Forums/Topic304718-163-1.aspx</link><description>&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana"&gt;Thanks, that you get attention to my wording (not many people captured it)&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana"&gt;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. &lt;/SPAN&gt;&lt;/P&gt;)</description><pubDate>Mon, 11 Sep 2006 18:42:00 GMT</pubDate><dc:creator>Leo Peysakhovich</dc:creator></item><item><title>RE: Identifying Unused Objects in a Database</title><link>http://www.sqlservercentral.com/Forums/Topic304718-163-1.aspx</link><description>&lt;P&gt;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...&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt; &lt;/P&gt;</description><pubDate>Mon, 11 Sep 2006 18:40:00 GMT</pubDate><dc:creator>SuperDBA-207096</dc:creator></item><item><title>RE: Identifying Unused Objects in a Database</title><link>http://www.sqlservercentral.com/Forums/Topic304718-163-1.aspx</link><description>Yes if you get cache in a short period time after they run. I was running tests every 2-3-5 minutes for 2 month. As I said you will have just the report of objects that MOST likely not used. Then additional analysis may required.</description><pubDate>Mon, 11 Sep 2006 18:30:00 GMT</pubDate><dc:creator>Leo Peysakhovich</dc:creator></item><item><title>RE: Identifying Unused Objects in a Database</title><link>http://www.sqlservercentral.com/Forums/Topic304718-163-1.aspx</link><description>&lt;P&gt;You forgot actually run the function or proc first before test it in cache memory&lt;/P&gt;&lt;P&gt;&lt;FONT color=#dd3333&gt;select name, id from sysobjects where name = 'get_emp_list_FY06' &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;&lt;U&gt;&lt;FONT color=#ff11ff&gt;exec get_emp_list_FY06&lt;/FONT&gt;&lt;/U&gt;&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Then:&lt;/P&gt;&lt;P&gt;&lt;FONT color=#3333dd&gt;select bucketid, cacheobjtype, objtype, objid, dbid       from master.dbo.SYSCACHEOBJECTS where  objid = 1718297181&lt;/P&gt;&lt;/FONT&gt;&lt;P&gt;&lt;FONT color=#3333dd&gt; &lt;/P&gt;&lt;/FONT&gt;</description><pubDate>Mon, 11 Sep 2006 18:27:00 GMT</pubDate><dc:creator>Leo Peysakhovich</dc:creator></item><item><title>RE: Identifying Unused Objects in a Database</title><link>http://www.sqlservercentral.com/Forums/Topic304718-163-1.aspx</link><description>&lt;P&gt;One of my pet peeves is when somebody will read a question and either they don't understand it, or they don't know the answer -- does that stop them? Nope - they just reply to a different question that they do know the answer to. Human nature, I guess. End of rant.&lt;/P&gt;&lt;P&gt;If you re-read Leo's original article, he said:&lt;/P&gt;&lt;P&gt;"In my company the task becomes a little bit easier by knowing the fact that any database can be accessed only via call to a stored procedure. E.g. I have to split the task to the 2 sequential subtasks: ..."&lt;/P&gt;&lt;P&gt;Lucky Leo. In his case, he could very easily add some kind of logging feature that records when an sp is run, and then (over the course of time) use a process of elimination to find the sp's that never get called.&lt;/P&gt;&lt;P&gt;Considering that SQL Server is notorious for omitting relevant object info such as "last modified" and "last accessed" dates (which Windows itself has had for ages) we're just a little bit stuck. Even perusing the SQL-DMO library does not reveal anything that I can find relating to the topic at hand. It really gets tiring when you have to drop-and-create procedures to track when changes happen.&lt;/P&gt;&lt;P&gt;The issue becomes even more complex when you consider that an external application can be allowed to touch objects directly, so even the internal SQL tracking mechanisms such as dependencies don't help a bit. I can think of one customer's web app that uses SQL Server, however there is also an Access database that connects in there, along with Excel gurus who use the Data tools to run their own specialized analyses. And let's not forget an e-commerce link to both their physical and online stores.&lt;/P&gt;</description><pubDate>Mon, 11 Sep 2006 10:31:00 GMT</pubDate><dc:creator>WILLIAM MITCHELL</dc:creator></item><item><title>RE: Identifying Unused Objects in a Database</title><link>http://www.sqlservercentral.com/Forums/Topic304718-163-1.aspx</link><description>"select name, id from sysobjects where name = 'get_emp_list_FY06'"calls the sysobjects table, so your query puts in cache the SYSOBJECTS table not your sp/fn.</description><pubDate>Mon, 11 Sep 2006 10:07:00 GMT</pubDate><dc:creator>Majbou-204206</dc:creator></item><item><title>RE: Identifying Unused Objects in a Database</title><link>http://www.sqlservercentral.com/Forums/Topic304718-163-1.aspx</link><description>Because it isn't cached.</description><pubDate>Mon, 11 Sep 2006 09:54:00 GMT</pubDate><dc:creator>Robert Davis</dc:creator></item><item><title>RE: Identifying Unused Objects in a Database</title><link>http://www.sqlservercentral.com/Forums/Topic304718-163-1.aspx</link><description>&lt;b&gt;Exactly&lt;/b&gt; what I was looking for &lt;img src='images/emotions/smile.gif' height='20' width='20' border='0' title='Smile' align='absmiddle'&gt;</description><pubDate>Mon, 11 Sep 2006 07:27:00 GMT</pubDate><dc:creator>sheepoo</dc:creator></item><item><title>RE: Identifying Unused Objects in a Database</title><link>http://www.sqlservercentral.com/Forums/Topic304718-163-1.aspx</link><description>&lt;P&gt;I wouldn't trust this post either. Now that the ASP and .net junkies can reach in and do stuff via the CLR, it's anybody's guess. And it is still so vexing that MS did not see fit to add attributes like "last modified" and "last accessed" in SS 2005 - Windows has had that capability for a long time.&lt;/P&gt;&lt;P&gt;AFAIK the only sure way to track when an sp is invoked would be to add tracking code e.g. write to a table when it is executed.&lt;/P&gt;</description><pubDate>Mon, 11 Sep 2006 07:27:00 GMT</pubDate><dc:creator>WILLIAM MITCHELL</dc:creator></item><item><title>RE: Identifying Unused Objects in a Database</title><link>http://www.sqlservercentral.com/Forums/Topic304718-163-1.aspx</link><description>This one scares me a little bit; if you have some procs that are run once a quarter or once a month would they show up in the cache?</description><pubDate>Mon, 11 Sep 2006 07:07:00 GMT</pubDate><dc:creator>SuperDBA-207096</dc:creator></item><item><title>RE: Identifying Unused Objects in a Database</title><link>http://www.sqlservercentral.com/Forums/Topic304718-163-1.aspx</link><description>&lt;P&gt;I used &lt;/P&gt;&lt;P&gt;&lt;FONT color=#dd3333&gt;select name, id from sysobjects where name = 'get_emp_list_FY06' &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color=#dd3333&gt;to get my objid. then I run this &lt;/FONT&gt;&lt;FONT color=#3333dd&gt;select bucketid, cacheobjtype, objtype, objid, dbid       from master.dbo.SYSCACHEOBJECTS where  objid = 1718297181&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color=#3333dd&gt;it return &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color=#3333dd&gt;bucketid    cacheobjtype      objtype  objid       dbid   ----------- ----------------- -------- ----------- ------ &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color=#3333dd&gt;(0 row(s) affected)&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color=#3333dd&gt;&lt;/FONT&gt; &lt;/P&gt;&lt;P&gt;&lt;FONT color=#3333dd&gt;Why ? Thanks.&lt;img src='images/emotions/doze.gif' height='20' width='20' border='0' title='Doze' align='absmiddle'&gt;&lt;img src='images/emotions/doze.gif' height='20' width='20' border='0' title='Doze' align='absmiddle'&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color=#3333dd&gt;&lt;/FONT&gt;&lt;FONT color=#3333dd&gt; &lt;/P&gt;&lt;/FONT&gt;</description><pubDate>Mon, 11 Sep 2006 05:42:00 GMT</pubDate><dc:creator>Frances L</dc:creator></item><item><title>Identifying Unused Objects in a Database</title><link>http://www.sqlservercentral.com/Forums/Topic304718-163-1.aspx</link><description>Comments posted to this topic are about the content posted at &lt;A HREF="temp"&gt;temp&lt;/A&gt;</description><pubDate>Tue, 29 Aug 2006 10:41:00 GMT</pubDate><dc:creator>Leo Peysakhovich</dc:creator></item></channel></rss>