Today, I used the attach function of SQL Server 2008 to attach a database. A problem occurred. The error message is:
Unable to open physical file "D: \ Documents ents \ dalt \ XXXX. MDF" Operating System Error 5: "5 (error not found)" (Microsoft SQL Server: Error 5120 )".
I remember that there was no problem with the previous operations. I don't know why, so I can't find a solution on the Internet,
Http://social.msdn.microsoft.com/Forums/en/sqldatabaseengine/thread/9e563890-e35f-4524-82b9-3cca08fec5ed
In the msdn forum, you need to add a user permission to the. MDF and. LDF files. Run the following statement to find the permission name.
1 declare @sqlser varchar(20)
2 EXEC master..xp_regread @rootkey='HKEY_LOCAL_MACHINE', @key='SYSTEM\CurrentControlSet\Services\MSSQLSERVER',
3 @value_name='objectname', @value=@sqlser OUTPUT
4 PRINT 'Account Starting SQL Server Service:' +convert(varchar(30),@sqlser)
The result on my machine is: account starting SQL Server Service: LocalSystem, right-click the folder containing the. MDF and. LDF files, switch to the security interface, and add the LocalSystem user. I cannot find this user here, as shown in figure
However, there are some users, such as: user (prchaz01210 \ User) and administrator (prchaz01210 \ User). I added the full control permission to the latter and tried attach again, I don't know what information the preceding statement found. I will wait for a while to check it out.