Search code examples
sql-server-2005lockingmdfldf

Cannot delete SQLServer2005 data or log files


I was trying to restore a backup but I kept getting OS error 32 - cannot delete because in use.

Couldn't figure out what was locking the data and log files - so I rebooted the machine, stopped the service but still no luck.

Then I deleted the DB but data and log files are still there.

Rebooted again - tried to delete them but looks like there's no thing to do, windows doesn't let me.

Any idea?


Solution

  • Antivirus software is one that catches DBAs - the MDF/LDF files are pretty big, and I've seen cases where the AV software grabs a lock on the files to scan them, but it takes forever due to the file size. You might try stopping your antivirus service.

    Another one is backup programs - if you're using file-based backups (like Backup Exec or NetBackup) they may be trying to run a file backup at the time. Check for any backup software services, stop those, and then try to delete the files.

    You might also have multiple instances of SQL Server installed, and this might belong to another instance, not the one you were working with.