Sql-server – How to determine what MDF files are in use

sql-server-2008

I just right-click deleted all my databases that were not in use. However all the MDF and LDF files are still in the data folder on the machine. What is the best way to determine what MDF and LDF files I can remove since the database no longer exists in SSMS.

Also is this the best way to delete unused databases? (The right-click -> Delete method.)

Best Answer

The Best way to delete databases in sql server is using DROP DATABASE command . If you right click and delete in SSMS you will end up with files left in folder .

Then You have to manually remove the files from server folder .

To remove these files from folder , first bring sql server to online then go the folder and start deleting the files , when deleting mdf or ldf files you will get error like files in use means that database you are using and you can remove remaining .