CREATE FILE encountered operating system error 5(failed to retrieve text for this error. Reason: 15105)
SqlSql Server-2008Sql Server-ExpressSql Problem Overview
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?
Sql Solutions
Solution 1 - Sql
I was able to solve the problem running MS SQL Management Studio as ADMINISTRATOR.
Solution 2 - Sql
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$
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...
Solution 3 - Sql
Right Click on File mdf and ldf properties -> security ->full permission
Solution 4 - Sql
Giving admin rights or full control to my database install location solved my problem
Solution 5 - Sql
I had the same problem. After several tries, I realized that connecting the sql server with windows authentication resolved the issue.
Solution 6 - Sql
Start->Run->services.msc
->scroll through the list of services until you find SQL Server->right-click->properties->Log On tab:
Then choose Local System Account
and check the Allow service to interact with desktop
checkbox.
Restart the service.
Solution 7 - Sql
I was getting similar error.
CREATE FILE encountered operating system error **32**(failed to retrieve text for this error. Reason: 15105) while attempting to open or create the physical file
I used the following command to attach the database:
EXEC sp_attach_single_file_db @dbname = 'SPDB',
@physname = 'D:\SPDB.mdf'
Solution 8 - Sql
This same problem occurs when the owners of the file have been deleted. When this happens, if you go to the file's properties, you will see a SID rather than a user name. Take ownership of the file (giving yourself FULL CONTROL). Once that is done you can do whatever you need to do with the file.
I've had this work when logging in as the administrator didn't do the trick.
Solution 9 - Sql
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.
Solution 10 - Sql
1.copy your --.MDF,--.LDF files to pate this location For 2008 server C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA 2.In sql server 2008 use ATTACH and select same location for add
Solution 11 - Sql
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!
Solution 12 - Sql
If you are already running as an adminstrator, make sure the user you are using has the proper server roles.
- Login as sa (if you can)
- Expand the Security folder
- Expand the Logins Folder
- Right click on the user you would like to use
- Select Properties
- Select Server Roles
- Select all the server roles
- Click OK
- Restart SSMS
- Login with the modified user
Solution 13 - Sql
In my case I have got the error when trying to create a databae on a new drive. To overcome the problem I created a new folder in that drive and set the user properties Security to full control on it(It may be sufficient to set Modify ). Conclusion: SET the Drive/Folder Properties Security for users to "Modify".
Solution 14 - Sql
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.
Solution 15 - Sql
copy your --.MDF
,--.LDF
files to pate this location For 2008 server C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA 2
.
In sql server 2008 use ATTACH and select same location for add
Solution 16 - Sql
Opening SSMS as Administrator and running as SQL Auth vs Windows Auth did not work.
What worked was to just change my filename to the same location where the LDF and MDF files are located.
alter database MyDB
add file ( name = N'FileStreamName',
filename = N'D:\SQL Databases\FileStreamSpace' )
to filegroup DocumentFiles;
Solution 17 - Sql
Here are the steps:
- Right click on the .mdf and .ldf file.
- Then select properties.
- On the security -> advanced -> permission add the user which
Solution 18 - Sql
I got this error when restoring a database that was backed up on another server. After a long struggle this is what I did
-
Enabled Instant File Initialization,
-
Granted permissions (full control) on the folder to the service account and my own windows account,
-
Restarted the SQL service. Database restored after that.
Solution 19 - Sql
The key is "operating system error 5". Microsoft helpfully list the various error codes and values on their site
https://msdn.microsoft.com/en-us/library/windows/desktop/ms681382(v=vs.85).aspx
ERROR_ACCESS_DENIED 5 (0x5) Access is denied.
Solution 20 - Sql
We faced this issue, when the windowsuser detaching the database and windowsuser attaching the database are different. When the windowsuser detaching the database, tried to attach it, it worked fine without issues.
Solution 21 - Sql
I just decided to create the file in D: instead of C: and everything worked well. windows 7...10 have many issues regarding the sharing and authorization of files and folder..
Solution 22 - Sql
In my case, Run as Administrator does not help. I solved the problem by changing the Build-in Account to Local System in Configuration Manager.
Solution 23 - Sql
Here is what happened in my case. I was asked to attach files for a database. I was given the file names as follows
- devdb.mdf and devdb.ldf
I proceeded to attach the files and kept getting the files are in use by another process.
I ran a query against the system view select name, physical_name from sys.master_files; and saw that the exact file names were already in use by another database, thus each time I tried to attach the files, I kept getting the error the files are in use by another process(sql server)
Thus if you are getting such a message, then also query against the system view sys.master_files and see which database may already be using the same name files. Hereafter you will figure out what to do.
thanks.
Solution 24 - Sql
if you have mount points add the the SQL server service account to volume security accordingly
Solution 25 - Sql
No need to do all this. Just right click on database files and add permission to everyone. That will work for sure.