I have a mdf file that is not attached but when I try to delete it Windows Explorer fails due to the file being in use. SQL Manager also says it's in use when I try to attach the MDF so that I can delete it. Is there a way to kill the connection and delete the file without stopping the SQL service? Thanks
Sql-server – How to delete mdf file in use but not attached
sql server
Related Question
- Sql-server – How to attach an .mdf file that was not properly detached
- Sql-server – How to restore mdf file in sql server 2005
- SQL Server – How to Identify Database .mdf and .ldf File Names?
- How to Attach a Damaged MDF File in SQL Server
- Sql-server – Not able to delete transaction log backup file
- Sql-server – How to resolve MDF and LDF files remaining in use
- SQL Server – How to Restore MDF without LDF File
Best Answer
Try to set the database (returned by the query in sys.master_files) Offline with
If the database is still seen in the dmv, it may still be possible to set it as offline (and then you'll be able to delete the file).
But if you want to delete the file, you could also just try to drop the database