Error deleting mdf file

  • I am trying to delete mdf file but getting following error.

    Cannot delete file access is denied

    Make sure the disk is not full or write-protected

    and that the file is not currently in use

    When I open Management Studio , there is no database related to this mdf file.

    This problem happens when I delete database using management studio and somehow it got stuck and then Ihave to kill the process. the process was in rollback state. after sometime database did disappear from the Management studio but some how mdf file still remain in the folder. I am trying to delete the mdf file but getting above error.

  • If you are sure that the file is not actually in use (Select * From sys.Master_Files Where physical_name = '<Path To File>'), it might simply be the file ownership. I have seen files owned by the SQL Server service account as well as the user account that restored/ created the database. Try right-clicking on the file and selecting Properties, go to the Security tab, click the Advanced button, select the Owner tab, select the appropriate user/ group under the “Change owner to:” section (e.g. Administrators, your account, etc.), click Apply, then OK out of the windows. Hope this helps.

  • Wow... It works.

    Thanks David.

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply