Though very annoying, it clearly points to a message, Access is denied. We have tested this scenario on Windows 7 using SQL Server 2008 R2 and SQL Server 2012 Express database. The database, which we are trying to attach, is from a previous version.
It is clearly an issue with permissions granted to users and administrator accessing the computer. The administrator by default will have full control on files and folders, whereas users may or may not have the necessary permissions.
If you have logged in to your computer as an USER and not as an ADMINISTRATOR then you need to follow these steps to fix the problem.
01) Right click the .mdf file and choose Properties.
02) In the properties dialog box, select the Security tab, which will show you a list of Group or user names. Each group and user names in list will have specific permissions assigned to them.
03) Click the Edit... button, which will open the Permissions dialog box. You need to find Users (… from the list and select it by clicking it.
04) You can now either Allow or Deny necessary permissions to the users according to their privileges. We suggest you check the option Allow for Full control and click the Apply button.
05) Repeat the same procedure with the .log file too. Both .mdf and .log files should have similar permissions.
06) Finally try to attach the database on your new SQL server database.
This is not a very serious issue and can be addressed and solved with ease, but sometimes these little errors does take away precious time and can also be frustrating while migrating from an older platform (version) to a newer one.
Thanks for reading. ☺