locked
this is what showing up when i tried to attach a mdf file to database RRS feed

  • Question

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

    Attach database failed for Server 'LAPTOP-NI0BU4DA\SQLEXPRESS'.  (Microsoft.SqlServer.Smo)

    For help, click: https://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=16.100.37971.0&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:\Project\New folder\New folder\HOSPITAL_MANAGEMENT_SYSTEM_IN_C_WITH_SOURCE_CODE\HospitalManagementSystem_C#\HospitalManagementSystemCSharp\HospitalManagementSystemCSharp\hospital.mdf". Operating system error 5: "5(Access is denied.)".
    CREATE DATABASE failed. Some file names listed could not be created. Check related errors. (Microsoft SQL Server, Error: 5120)

    For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft%20SQL%20Server&ProdVer=15.00.2000&EvtSrc=MSSQLServer&EvtID=5120&LinkId=20476

    ------------------------------
    BUTTONS:

    OK
    ------------------------------
    Saturday, July 4, 2020 6:49 AM

All replies

  • Hi ElactixNovae,

    >> Unable to open the physical file "D:\Project\New folder\New folder\HOSPITAL_MANAGEMENT_SYSTEM_IN_C_WITH_SOURCE_CODE\HospitalManagementSystem_C#\HospitalManagementSystemCSharp\HospitalManagementSystemCSharp\hospital.mdf". Operating system error 5: "5(Access is denied.)".

    According to your error message, your SQL server service account did not have the read and write permission on the folder D:\Project\New folder\New folder\HOSPITAL_MANAGEMENT_SYSTEM_IN_C_WITH_SOURCE_CODE\HospitalManagementSystem_C#\HospitalManagementSystemCSharp\HospitalManagementSystemCSharp\hospital.mdf".

    Please try the follow steps to solve the issue.
    1.Find Service Account for SQL Server
    2. Right click the (mdf/ldf) files or the folder and select “Properties”.
    3. Select “Security” tab and click the “Edit” button.
    4. Add SQL server service account and give this service account “Full control” to the file or the folder.
    5. Click “OK” button.
    6.Attach the db again,refer to the blog Different methods to attach SQL Server MDF files

    Please also make sure the location of the mdf file is correct.

    Best regards,
    Cathy 

    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to  MSDN Support, feel free to contact MSDNFSF@microsoft.com



    Monday, July 6, 2020 6:22 AM
  • Hi ElactixNovae,

    Is there any progress?If the reply could help you, please kindly mark the useful reply as answer.This can be beneficial to other community members reading the thread.
    In addition, if you have another questions, please feel free to ask.
    Thanks for your contribution.

    Best regards,
    Cathy

    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to  MSDN Support, feel free to contact MSDNFSF@microsoft.com

    Tuesday, July 7, 2020 8:12 AM