question

Mrs_Fatherjack avatar image
Mrs_Fatherjack asked

Removing orphaned files

I'm hoping this is a fairly simple one. I have just discovered lots of orphaned files, due to colleagues (and myself - every day is a school day) not knowing that if you delete a database when it's offline it doesn't remove the associated files. I've got a list of these files, thanks to DBATools, however which is the best way to remove them, should I: a) delete the files by hand or b) recreate the database by attaching the files? Many thanks in advance for the advice.
orphan files
1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Personally, I would delete them by hand. I've run into this before and I just deleted the files. Or move them off to a secondary folder for safe keeping for a period of times and then delete them. Just my opinion though.
1 Like 1 ·

1 Answer

·
Tim avatar image
Tim answered
The easiest way is to just delete them manually. No need to attach and then drop the database. I am not publicly recommending this, but if all you have on the drive or in the folder is supposed to be active db files, you could select all, and delete and ignore the in-use files. Have I done that before, yep, did I have issues no. Could it be an issue if someone had a detached database they planned to reattach, sure thing. However the shop I was working at, that wouldn't have been the case. So, sure, just delete the files you know aren't needed.
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.