locked
Unable to attach database RRS feed

  • Question

  • I am trying to attach a database to my SQL Server Express Instalaltion and am getting the following error message

    TITLE: Microsoft SQL Server Management Studio
    ------------------------------

    Attach database failed for Server 'DOUG-PC\SQLEXPRESS'.  (Microsoft.SqlServer.Smo)

    For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=10.50.1600.1+((KJ_RTM).100402-1540+)&EvtSrc=Microsoft.SqlServer.Management.Smo.ExceptionTemplates.FailedOperationExceptionText&EvtID=Attach+database+Server&LinkId=20476

    ------------------------------
    ADDITIONAL INFORMATION:

    An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo)

    ------------------------------

    Unable to open the physical file "D:\Users\Doug\Documents\Visual Studio 2008\Projects\ToxoFlite\ToxoFlite Database\ToxoFlite.mdf". Operating system error 5: "5(failed to retrieve text for this error. Reason: 15105)". (Microsoft SQL Server, Error: 5120)


    Do the two database file "(mdf and ldf) need to be in the SQL server binn folder, if so what is the correct folder for me to copy the files to.

     

    Anyt help greatly appreciated.

     

    Regards,

     

    Doug U-M

    Sunday, June 13, 2010 8:05 PM

Answers

  • >>Do the two database file "(mdf and ldf) need to be in the SQL server binn folder, if so what is the correct folder for me to copy the files to.

    No, you do not need to keep files in binn folder.

    Generally speaking operating system Error 5 means insufficient permission.

    Make sure account under which SQL Sever service is running has (read/wirte)  access to the folder i.e.

    D:\Users\Doug\Documents\Visual Studio 2008\Projects\ToxoFlite\ToxoFlite Database\

    from where you want to attach your database.

     

    • Right click on the folder D:\Users\Doug\Documents\Visual Studio 2008\Projects\ToxoFlite\ToxoFlite Database\  and click on properties
    • Click on security tab
    • Click on Add button and add sql service account
    • Provide modify privilege and click ok
    • Verify both mdf and ldf have modify privilege
    • Attach the db
    Sunday, June 13, 2010 8:44 PM

All replies

  • >>Do the two database file "(mdf and ldf) need to be in the SQL server binn folder, if so what is the correct folder for me to copy the files to.

    No, you do not need to keep files in binn folder.

    Generally speaking operating system Error 5 means insufficient permission.

    Make sure account under which SQL Sever service is running has (read/wirte)  access to the folder i.e.

    D:\Users\Doug\Documents\Visual Studio 2008\Projects\ToxoFlite\ToxoFlite Database\

    from where you want to attach your database.

     

    • Right click on the folder D:\Users\Doug\Documents\Visual Studio 2008\Projects\ToxoFlite\ToxoFlite Database\  and click on properties
    • Click on security tab
    • Click on Add button and add sql service account
    • Provide modify privilege and click ok
    • Verify both mdf and ldf have modify privilege
    • Attach the db
    Sunday, June 13, 2010 8:44 PM
  • MAny thanks for the answer, just a bit of expansion required.  Ho do I add a "sql service account" to the folder?  I am not sure what you are talking about here.  If it helps ny OS is Windows 7.

     

    ANy help greatl;y appreciated.

     

    Regards - Doug U-M

    Tuesday, June 15, 2010 7:21 PM
  • You need to determine SQL Server service account first.. (many times I see it is Network Service account but you need to check your install)

    the link below has screenshot that will help you find out service account used for SQL server


    http://www.sql-articles.com/articles/general/sql-server-service-accounts

    after that I think I replied in my previous post

    • Right click on the folder D:\Users\Doug\Documents\Visual Studio 2008\Projects\ToxoFlite\ToxoFlite Database\  and click on properties
    • Click on security tab
    • Click on Add button and add sql service account
    • Provide modify privilege and click ok
    • Verify both mdf and ldf have modify privilege
    • Attach the db

     

    Wednesday, June 16, 2010 2:21 PM