"Error Tip"
Cannot retrieve data for this request. (Microsoft.SqlServer.SmoEnum) An exception occurred while other information was executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo) when attempting to open or create a physical file "D:\data\***.mdf", the Create file encounters operating system error 5 (Access denied.) )
"Problem Background"
Database version: SQL Server 2005 Enterprise Edition
Operating system version: Windows Server 2003 Enterprise Edition
Error-Raising Description: After the database is detached, the data hard disk is swapped from one host to another (the operating system and database version of the two hosts are the same). When you attach a database, you are prompted for an error.
"Problem Analysis"
Obviously, it is the problem that the file operation authority is not enough.
"Workaround"
You can solve the problem by adding the appropriate user to the folder attribute security of the database file and giving the full Operation permission (the information on the Web is all that). Add permissions to what user? For example: Administrators user group, Network Service, Mssqluser or everyone, specifically, see which account your SQL service started, if not clear or lazy, you can directly add everyone user. Originally wanted to last screenshot, do not know why, dozens of KB of pictures, has been uploaded unsuccessfully.
"Unexpected Situation"
Perhaps you through the above solution, to the data file in the folder where the corresponding user and operation permissions, but the problem is still (this is my pain in the place, the internet is so said, I do not can not miles ~~??! )。 Finally, my solution is to set the user and operation permissions for each database file (including MDF, LDF, NDF), respectively, as well as the security options in the right key attribute, as is the operation method and the permissions to the folder. The problem has finally been solved completely. The reason for this is that the permissions for the folder are not automatically inherited to the file inside.