0

This is the strangest thing ever. My company's product uses a database file with Microsoft SQL Server 2008 R2, let's just say it's named myDB.mdf. I want to delete that file and replace it with a same-named database from another system. So I try to delete it, and of course I can't because it's in use by some process. I reboot specifically to ensure that nothing's still running that has that file open, and I still can't delete it (same reason). I fire up Sysinternals ProcessExplorer and Find->Find Handle or DLL and enter the filename. The process that has it open is named 'System' and has a PID of 4. So I go to Control Panel -> Programs and Features and one-by-one, uninstall all of the components of Microsoft SQL Server 2008 R2. Still can't delete it. Oh, I have MS SQL Server 2012 installed... maybe that's it. Uninstall all components of that. And some other SQL thing from Microsoft, uninstall that too. Still can't delete it. Reboot. Don't open ANYTHING, and still can't delete it. It gives the error "File In Use: The action can't be completed because the file is open in System. Close the file and try again. [Try Again] [Cancel]". I opened up Control Panel -> Programs and Features again, and confirmed that there are no remaining SQL-ish things. And the file's icon is now a white sheet of paper with the top right edge folded over (i.e. it has no file association).

Any idea how I can make 'System' not open the file so I can delete it?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
phonetagger
  • 7,701
  • 3
  • 31
  • 55

1 Answers1

0

The correct action was to right-click on the database in SQL Management Studio and choose Delete. Undoing the steps you've taken may be very difficult. I'm assuming/hoping this is a dev server. Can you revert to snapshot or nuke the server and install on another?

Jon Tirjan
  • 3,556
  • 2
  • 16
  • 24
  • Hmm. No, this is my personal development workstation, a laptop. Can I re-install SQL Server 2008 R2 and then fire up SQL Management Studio? (Sorry, I'm not actually familiar with SQL Management Studio; normally our software just handles all the database stuff, in code that was written by people who are no longer at the company.) – phonetagger Apr 09 '15 at 13:28