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?
System error 5 is an error access denied code which means that your access is denied because you don't have the required privileges to run a certain command. For example, when you try to run a command which is supposed to stop the print spooler, you will get an error message.
The problem is due to lack of permissions for SQL Server to access the mdf & ldf files. All these procedures will work : you can directly change the MSSQLSERVER service startup user account, with the user account who have better privileges on the files. Then try to attach the database.
New pseudo-account is created called “NT SERVICE⧹MSSQLSERVER” or “NT SERVICE⧹SQLSERVERAGENT,” basically the account is “NT SERVICE” for the domain name followed by the name of the service. This allows each service to function within its own security context and not have access to the resource of another service.
I was able to solve the problem running MS SQL Management Studio as ADMINISTRATOR.
It's a Windows permissions issue. If you connected to your server using Windows Authentication then that Windows user needs permissions to the file. If you connected to your server using SQL Server authentication then the SQL Server instance account (MSSQL$, e.g. MSSQL$SQLEXPRESS) needs permissions to the file. The other solutions suggesting logging in as an administrator essentially accomplish the same thing (with a bit of a sledgehammer :).
If the database file is in your SQL Server's data folder then it should have inherited the user rights for the SQL Server account from that folder so the SQL Server authentication should have worked. I would recommend fixing the SQL Server instance's account's rights for that folder. If the data file is somewhere else and the SQL Server account does not have permissions then you will likely encounter other problems later. Again, the better solution is to fix the SS account rights. Unless you are always going to log in as administrator...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With