Attach Database Error after moving MDF

  • I needed to move the MDF to another location so I detached the database, and dragged the MDF to a new folder. I was thinking it had finished copying, so I attempted to attach it, but got an error because the MDF was in use. No surprise. After the copy finished, I tried to attach again, but now I get the error:

    "Unable to open the phuysical file "F:\log\search_log.LDF Operating system error 5 "Access is denied" SQL Error 5120.

    I did not make any changes to the LDF, so not quite sure why that is throwing the error.

    Any suggestions ?

  • "Access is denied" check if account, on which running sql server have sufficient rights

  • The SQL Server service does not have permissions on the log file or the directory it's in. Check the permissions, ensure that SQL Server service has full control over both folder and file.

    Log file, not data file.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • The permission problem seems like it would be a red herring. I had no trouble moving (detach/attach) a different database in the same folders. And I wasn't moving the log file, just the MDF.

  • Check the permissions, the error is OS error 5, that is a permission problem.

    Could be that in the detach the permissions on the files were changed, I have seen that. Usually the SQL Server service retains permissions, but worth checking.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • You are correct (as usual). All good now after manually putting permissions back on.

  • There are a number of reasons to rather do an OFF LINE rather than a DETACH when moving database files like this. In SQL 2005 there was a particular issue with permissions being lost, but it looks like this happens ocassionally in SQL 2008 as well. I've never seen this happening using OFF LINE.

    Another issue is a detach losses some database spesific configurations that are maintained in the MASTER database (e.g. cross database ownership chaining - not a recommended option), which aren't lost when an OFF LINE is used.

    Cheers

    Leo

    Leo
    Nothing in life is ever so complicated that with a little work it can't be made more complicated.

Viewing 7 posts - 1 through 6 (of 6 total)

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