<p>I'm working with a SQL Server 2000 database that likely has a few dozen tables that are no longer accessed.  I'd like to clear out the data that we no longer need to be maintaining, but I'm not sure how to identify which tables to remove.</p>

<p>The database is shared by several different applications, so I can't be 100% confident that reviewing these will give me a complete list of the objects that are used.</p>

<p>What I'd like to do, if it's possible, is to get a list of tables that haven't been accessed at all for some period of time.  No reads, no writes.  How should I approach this?</p>

[{'answer_id': 35087, 'author': 'SQLMenace', 'author_id': 740, 'author_profile': 'https://Stackoverflow.com/users/740', 'pm_score': 0, 'selected': False, 'text': '<p>If you have lastupdate columns you can check for the writes, there is really no easy way to check for reads. You could run profiler, save the trace to a table and check in there</p>\n\n<p>What I usually do is rename the table by prefixing it with an underscrore, when people start to scream I just rename it back</p>\n'}, {'answer_id': 35094, 'author': 'JasonS', 'author_id': 1865, 'author_profile': 'https://Stackoverflow.com/users/1865', 'pm_score': 0, 'selected': False, 'text': "<p>If by not used, you mean your application has no more references to the tables in question and you are using dynamic sql, you could do a search for the table names in your app, if they don't exist blow them away.</p>\n\n<p>I've also outputted all sprocs, functions, etc. to a text file and done a search for the table names.  If not found, or found in procedures that will need to be deleted too, blow them away.</p>\n"}, {'answer_id': 35100, 'author': 'Ricardo Reyes', 'author_id': 3399, 'author_profile': 'https://Stackoverflow.com/users/3399', 'pm_score': 4, 'selected': True, 'text': '<p>MSSQL2000 won\'t give you that kind of information. But a way you can identify what tables ARE used (and then deduce which ones are not) is to use the SQL Profiler, to save all the queries that go to a certain database. Configure the profiler to record the results to a new table, and then check the queries saved there to find all the tables (and views, sps, etc) that are used by your applications. </p>\n\n<p>Another way I think you might check if there\'s any "writes" is to add a new timestamp column to every table, and a trigger that updates that column every time there\'s an update or an insert. But keep in mind that if your apps do queries of the type </p>\n\n<pre><code>select * from ...\n</code></pre>\n\n<p>then they will receive a new column and that might cause you some problems. </p>\n'}, {'answer_id': 35157, 'author': 'tonygambone', 'author_id': 3344, 'author_profile': 'https://Stackoverflow.com/users/3344', 'pm_score': 0, 'selected': False, 'text': "<p>It looks like using the Profiler is going to work.  Once I've let it run for a while, I should have a good list of used tables.  Anyone who doesn't use their tables every day can probably wait for them to be restored from backup.  Thanks, folks.</p>\n"}, {'answer_id': 35197, 'author': 'Forgotten Semicolon', 'author_id': 1960, 'author_profile': 'https://Stackoverflow.com/users/1960', 'pm_score': 1, 'selected': False, 'text': '<p>Another suggestion for tracking tables that have been written to is to use <a href="http://www.red-gate.com/products/SQL_Log_Rescue/index.htm" rel="nofollow noreferrer">Red Gate SQL Log Rescue</a> (free).  This tool dives into the log of the database and will show you all inserts, updates and deletes.  The list is fully searchable, too.</p>\n\n<p>It doesn\'t meet your criteria for researching reads into the database, but I think the SQL Profiler technique will get you a fair idea as far as that goes.</p>\n'}, {'answer_id': 213915, 'author': 'John MacIntyre', 'author_id': 29043, 'author_profile': 'https://Stackoverflow.com/users/29043', 'pm_score': 0, 'selected': False, 'text': "<p>Probably too late to help mogrify, but for anybody doing a search; I would search for all objects using this object in my code, then in SQL Server by running this :</p>\n\n<p>select  distinct '[' + object_name(id) + ']'<br/>\nfrom    syscomments<br/>\nwhere   text like '%MY_TABLE_NAME%'</p>\n"}]
['https://Stackoverflow.com/questions/35076', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/3344/']