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
 Other Forums
 Other Topics
 Automatically deleting tables with the same prefix

Author  Topic 

graz
Chief SQLTeam Crack Dealer

4149 Posts

Posted - 2000-08-13 : 00:00:00
Joe asks "I have a database that gets new tables automatically added to it through some other process that goes on (not important). So this database keeps growing as these new tables are added. But these tables are not necessary after about 4 hours. Is there some way that I could automatically delete these tables that are over 4 hours old? All of these tables begin with the same prefix in their name. Let's just call that prefix "blah". Could you help me? Right now I have to manually go and delete them."

I would suggest using some combination of the Information Schema views and the SYSOBJECTS table. The SYSOBJECTS table has a created date (CRDATE) field in it. You could easily find each table older than a certain date and delete them.
   

- Advertisement -