locked
Getting an Error when Trying to Attach a Database RRS feed

  • Question

  • Hi.

    I just installed SQL Server 2014 and tried to attach a database.  I get an error that reads, "An error occurred when attaching the database(s).  Click the hyperlink in the Message column for details."  There is no hyperlink message.  Any ideas?  Is there a way I can "create" this db again by running a script?

    TIA.

    Tuesday, February 16, 2016 5:17 PM

Answers

  • Hi Ghymn,

    You may get the error when you attach the .MDF file without a log file to SQL Server.

    Please check if the database that you want to attach has the .log file. If it doesn’t have the log file, to solve this issue, you could remove log file task when attaching the .MDF file to SQL Server, then check if the error persists. For detailed information of attaching .MDF file without log file, there is blog for reference.

    In addition, if it has the log file and the error persists, the error also might be caused by that the account you are using to attach database doesn’t have enough privilege on the folder that holds the .MDF file and .LDF file. To solve this issue, you could copy the .MDF file and LDF file to the default folder where your service account has access permission( C:\Program Files\Microsoft SQL Server\MSSQL12.MSSQLSERVER\MSSQL\DATA), or grand your account full control permission, then attach the database. There is a blog for your reference.

    Regards,
    Ice Fan 


    Ice Fan
    TechNet Community Support


    Wednesday, February 17, 2016 10:00 AM

All replies

  • Please check my response here:
    https://social.msdn.microsoft.com/Forums/sqlserver/en-US/a266a91c-b737-4a84-8fd5-09b04f84dbda/uploading-adventure-works-in-a-ms-sql-server-2012-installed-in-virtual-machine-environment-vmware?forum=sqlgetstarted

    I am guessing that you have the same issue (you got the mdf file without the log file).

    If this is not the case, please give us more details. 
    * Which database you try to attach (where did you got it)
    * Check the full error message in the error log file
    * Anything else that might be relevant directly or indirectly.


    signature   Ronen Ariely
     [Personal Site]    [Blog]    [Facebook]    [Linkedin]



    • Edited by pituachMVP Wednesday, February 17, 2016 1:10 AM
    Tuesday, February 16, 2016 5:36 PM
  • Hi Ghymn,

    You may get the error when you attach the .MDF file without a log file to SQL Server.

    Please check if the database that you want to attach has the .log file. If it doesn’t have the log file, to solve this issue, you could remove log file task when attaching the .MDF file to SQL Server, then check if the error persists. For detailed information of attaching .MDF file without log file, there is blog for reference.

    In addition, if it has the log file and the error persists, the error also might be caused by that the account you are using to attach database doesn’t have enough privilege on the folder that holds the .MDF file and .LDF file. To solve this issue, you could copy the .MDF file and LDF file to the default folder where your service account has access permission( C:\Program Files\Microsoft SQL Server\MSSQL12.MSSQLSERVER\MSSQL\DATA), or grand your account full control permission, then attach the database. There is a blog for your reference.

    Regards,
    Ice Fan 


    Ice Fan
    TechNet Community Support


    Wednesday, February 17, 2016 10:00 AM