CREATE FILE encountered operating system error 5(f

2019-01-22 10:51发布

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?

23条回答
别忘想泡老子
2楼-- · 2019-01-22 10:55

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.

查看更多
Melony?
3楼-- · 2019-01-22 10:57

I had the same problem. After several tries, I realized that connecting the sql server with windows authentication resolved the issue.

查看更多
看我几分像从前
4楼-- · 2019-01-22 10:57

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.

查看更多
Animai°情兽
5楼-- · 2019-01-22 10:59

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.

查看更多
欢心
6楼-- · 2019-01-22 11:03

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.

查看更多
不美不萌又怎样
7楼-- · 2019-01-22 11:04

Right Click on File mdf and ldf properties -> security ->full permission

查看更多
登录 后发表回答