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
 SQL Server Administration (2005)
 Deleting offline db doesn't delete data files

Author  Topic 

dhjackal
Starting Member

42 Posts

Posted - 2009-06-03 : 10:48:23
I have an interesting problem ;

if i offline a database and then delete it the physical database data files are not deleted from disk. Is this expected? If i delete the database without first off lining it the underlying data files are deleted?



This is all on SQL Server 2005 SP2 (all through SSMS)

mcrowley
Aged Yak Warrior

771 Posts

Posted - 2009-06-03 : 11:29:30
this is the expected behaviour. If you drop a database that is online, SQL Server will delete all of the data files.
Go to Top of Page

dhjackal
Starting Member

42 Posts

Posted - 2009-06-03 : 11:37:32
If it's expected behaviour then fair enough.

We have a third party app that is supposed to manage the databases that it creates. However i've found that the process for deletion takes the database offline and then a job runs overnight to delete. Because of this the database is removed from SQL Server but the database data files remain.

I've gotten round the issue by writing a script which checks the physical file location for associated .mdf .ldf files and if they are redundant deletes them.


Go to Top of Page
   

- Advertisement -