The operating system returned the error '5(Access is denied.)' while attempting 'RestoreContainer::ValidateTargetForCreation' on 'D:\RATING_DEV.mdf' at 'container.cpp'(2731).
This issue is due to the insufficient permission to the account configured to run SQL Server Database Engine on file system access to the location where database files are stored.
Beginning with SQL Server 2012 permissions are assigned to the per-service SID for each of its services. If you configured the SQL Server Database Engine service to run on account "NT SERVICE\MSSQLSERVER". The permission to the default location is configured during setup. If you place your database files in a different location, you might need to follow these steps to grant the Database Engine the full control permission to that location.
To grant file system permission to the per-service SID
- Using Windows Explorer, navigate to the file system location where the database files are stored. Right-click the file system folder, and then clickProperties.
- On the Security tab, click Edit, and then Add.
- In the Select Users, Computer, Service Account, or Groups dialog box, click Locations, at the top of the location list, select your computer name, and then click OK.
- In the Enter the object names to select box, type the name of the per-service SID listed in the Books Online topic Configure Windows Service Accounts and Permissions. (For the Database Engine per service SID, use NT SERVICE\MSSQLSERVER for a default instance, or NT SERVICE\MSSQL$InstanceName for a named instance.)
- Click Check Names to validate the entry. The validation often fails, and might advise you that the name was not found. When you click OK, a Multiple Names Found dialog box appears.
- Now select the per-service SID, either MSSQLSERVER or NT SERVICE\MSSQL$InstanceName, and then click OK.
- Click OK again to return to the Permissions dialog box.
- In the Group or user names box, select the per-service SID, and then in the Permissions for <name> box, select the Allow check box for Full control.
- Click Apply, and then click OK twice to exit.
For more details click HERE.