I have a database file .mdf
from MS SQL EXPRESS in folder:
C:\Program Files\Microsoft SQL Server\MSSQL10.SQLEXPRESS\MSSQL\DATA
I would like to attach it to MS 2008 R2 (MSSQL10_50.MSSQLSERVER) but using Server Management Studio I receive the following error:
CREATE FILE encountered operating system error 5(failed to retrieve text for this error. Reason: 15105) while attempting to open or create the physical file
Do you have any idea how to solve it?
As other suggested running as administrator will help.
However this only if the windows user is actually an admisnitrator on the machine which sql server runs.
For example when using SSMS from a remote machine it will not help using "run as administartor" if the user is only a administrator on the machine runing SSMS but not on the machine running SQL Server.
My solution was slightly more complicated. After verifying the user the service was running as, running MSSMS as local and domain administrator, and checking folder permissions, I was still getting this error. My solution?
Folder ownership was still maintained by local account.
Properties > Security > Advanced > Owner > (domain/local user/group SQL services are running as)
This resolved the issue for me.
No need to do all this. Just right click on database files and add permission to everyone. That will work for sure.
I was getting similar error.
I used the following command to attach the database:
I was able to solve the problem running MS SQL Management Studio as ADMINISTRATOR.
I had this issue on Windows 2003 with SQL 2005. I had to take ownership of the files as my Windows user account and I got the database to attache that way.
You have to right click on the file, select Properties, click OK to get past the information screen, click the Advanced button, select your account from the listing of available accounts or groups, apply that change, and Click OK on the Properties screen. Once you have done all that you will be able to manage the file permissions.
I logged into SSMS with Windows Authentication and I was able to attach the database without error.
Cheers!