problem attaching AdventureWorks2008R2_Data.mdf in SSMS


  • Hi,

    I am getting an error message when trying to attach AdventureWorks2008R2_Data.mdf in SSMS.  An error message pops up and says:

    Failed to retrieve data for this request. (Microsoft.SqlServer.Management.Sdk.Sfc)

    Additional information:

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

    CREATE FILE encountered operating system error 5(Access is denied.) while attempting to open or create the physical file 'C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\AdventureWorks2008R2_Data.mdf'. (.Net SqlClient Data Provider)

    Server Name: (local)
    Error Number: 5123
    Severity: 16
    State: 20
    Line Number: 1

    Does anyone know what is wrong and how to fix this?


    • Modifié Knot dimanche 18 septembre 2011 15:18
    dimanche 18 septembre 2011 15:18


Toutes les réponses

  • Hi,
    You are attaching mdf file on same version?
    First Detach it from old DB then try.

    lundi 19 septembre 2011 06:06
  • No, actually I'm trying to attach it on a new computer on a new installation of SQL Server 2008R2 Developer's Edition.  Could it have anything to do with not having an Admin account?  How do I check if there is an Admin account and if there isn't how do I add one?
    mardi 20 septembre 2011 22:57
  • Hello ,

    some links about this problem :

    2 possible reasons :

    - the .mdf file is in a read-only state ( classical if the file has been copied from a CD/DVD where the files are read-only usually )

    - the login you used to execute your T-SQL CREATE DATABASE FOR ATTACH has not the correct access to the folder where you have your .mdf file

    Don't hesitate to post again for more help or explanations

    Have a nice day

    PS : a stupid question : how have you detached your database ?

    PS2 : when you try to attach database files from a more recent version , the error message is different , maybe the 968 message

    Mark Post as helpful if it provides any help.Otherwise,leave it as it is.

    • Modifié Papy Normand lundi 26 septembre 2011 17:22 PS2 added
    • Marqué comme réponse Knot mercredi 28 septembre 2011 01:13
    • Non marqué comme réponse Knot mercredi 28 septembre 2011 01:13
    • Marqué comme réponse Knot mercredi 28 septembre 2011 01:35
    lundi 26 septembre 2011 17:09
  • Hello Papy,

    Thank-you for the information.  I am not quite sure how this happened but some time between posting this problem and now the downloaded AdventureWorks databases appeared in SSMS.  Perhaps it was after a reboot...?  It was possible to see them in Quest's Toad 5.5 before they were visible in SSMS.  Anyhow, this seems to have remedied itself!  About your PS #1 Papy - the download instructions I was following said it would be necessary to attach the databases in SSMS by right clicking on the Databases node & then clicking Attach.

    • Modifié Knot mercredi 28 septembre 2011 01:13
    • Marqué comme réponse Knot mercredi 28 septembre 2011 01:35
    mercredi 28 septembre 2011 01:13
  • Hi, I solved this problem when I place AdventureWorks2008R2_Data.mdf to next location C:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\Backup. It is a folder of MSSQL backup files.


    • Modifié Sashus samedi 13 juillet 2013 14:01 typing error
    • Proposé comme réponse Papy Normand dimanche 21 juillet 2013 15:47
    samedi 13 juillet 2013 13:58