Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Table Last Accessed/Delete Large amounts of data

Author  Topic 

ddobbertin
Yak Posting Veteran

51 Posts

Posted - 2007-04-02 : 14:57:45
Hello everyone...does anyone have a slick way that I can determine when the last time a table was accessed? I inherited an SQL server that has a ton of tables that seem obsolete however I need to verify they have not been accessed before dropping them.

Also I have a few tables with 100 million + records that I am having difficulty purging data from due to timeout issues. Any advice?

Thanks in advance!

dinakar
Master Smack Fu Yak Hacker

2507 Posts

Posted - 2007-04-02 : 18:04:46
As much as I dont like to suggest using triggers, you could create a trigger on tables you think are not being accessed and have it insert some value (like the table name) into another location/table. You can disable the trigger as soon as you get at least one record from a table so there's no more additional overhead.

To delete 100 mill + rows, its better to do it in batches. You can also do it in a while loop.

-----------
SET ROWCOUNT 500000
DELETE ....
SET ROWCOUNT 0
Go



************************
Life is short. Enjoy it.
************************
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2007-04-03 : 06:40:31
"I am having difficulty purging data from due to timeout issues"

See: http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=77084

Kristen
Go to Top of Page
   

- Advertisement -