Home » Blog » Topic » Getting Error while Attaching the Database in SQL Server

Getting Error while Attaching the Database in SQL Server

Stephen West ~ Modified: December 25th, 2015 ~ ~ 1 Minute Reading

Home Forums Getting Error while Attaching the Database in SQL Server

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #1010 Score: 0
    Stephen West
    Moderator
    4 pts

    I have a MDF file and no associated LDF file for a database created in MS SQL Server 2008. When I am trying to attach the MDF file to a different SQL Server, then I am facing error..

    Unable to open the physical file “D:\Database2.mdf”. Operating system error 5: “5(Access is denied.)”. (Microsoft SQL Server, Error: 5120)

    #1017 Score: 0
    Lincoln Burrows
    Moderator
    16 pts

    You need to provide the modify privilege to the SQL Service accounts to the folder C:\ArrowSQL\Arr@Data and then attach the db, it will attach without privilege error!!
    Now, if you are using windows 7. Open the SSMS like this – Right click -> Run as Administrator and then login in windows mode and try to attach the database files.

    #1727 Score: 0
    Stephen West
    Moderator
    4 pts

    When I followed the instructions given by you, the same error prompted that’s why I am unable to attach the .mdf file. What may the possible reasons for this error?

    #1825 Score: 0
    Michael Scofield
    Moderator
    20 pts

    Please make sure that .mdf file and .ldf file on the same drive

    #2068 Score: 0
    Michael Scofield
    Moderator
    20 pts
    • Go to the folder where mdf file is stored.
    • Select file
    • Right click on the file
    • Give full permissions to file for logged in user Security. 
    #2075 Score: 0
    Andrew Jackson
    Moderator
    1 pt

    What may the possible reasons for this error?

    The problem of operating system error 5(access is denied.) is due to lack of permissions for SQL Server to access the Primary (.mdf) & Log (.ldf) files.

    And to fix this error
    Change the MSSQLSERVER service startup user account, with the user account who have better privileges on the files and then try to attach the database.
    Or
    Startup with windows administrator account, and open SQL Server with run as administrator option and try to login with windows authentication and now try to attach the database.

    #2080 Score: 0
    Stephen West
    Moderator
    4 pts

    Thanks Andrew and Michael for your clarifications, I have fixed my problem

Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.