4

I got message box

Unable to open the physical file "C:\Project Basdat\DAYCARE.mdf". Operating system error 5: "5(failed to retrieve text for this error. Reason: 15105)". (Microsoft SQL Server, Error: 5120)

when trying to attach database file that I made from another pc.

I use Windows 10.

Help :(

BytesOfMetal
  • 664
  • 10
  • 24
Yeremia Danang P
  • 53
  • 1
  • 1
  • 3
  • Error 5 is access denied, either put the database files in the SQL server data folder that was defined during setup or add permissions on that new folder to allow the service account access to it. – steoleary May 25 '16 at 09:29
  • 1
    Possible duplicate of [SQL Server Operating system error 5: "5(Access is denied.)"](https://stackoverflow.com/questions/18286765/sql-server-operating-system-error-5-5access-is-denied) – Andre Figueiredo Mar 21 '18 at 21:15

3 Answers3

10

The link I posted previously is broken so I removed it. If you run SQL Server Management Studio as administrator it should work just fine.

BytesOfMetal
  • 664
  • 10
  • 24
0

This is permission issue on folder.

GO to the folder where you have stored mdf file. select file-> Right click -> click on . give full permissions to file for logged in user Security and (NT Service\MSSQLSERVER).

sandeep rawat
  • 4,797
  • 1
  • 18
  • 36
  • 1
    This is correct assuming you are using the default built in accounts for SQL server, if you have used a different service account, you need to add folder permissions that reflect this. – steoleary May 25 '16 at 09:27
0

When I faced this issue, I tried

  1. Running SQL Management Studio as Administrator
  2. Giving full permissions to the file for logged in user

Still the error persisted. The reason for this error might be that you copied your program from a source which Windows considers non-trusted.

You can unblock the assembly by clicking "Unblock" after you right-click and select properties on the file.