Reputation: 25701
I backed up a database from a SQL Server 2005 using my SSMS Task and called it datalab_auth.bak
.
I then tried to restore it to my SQL Server 2012 but keep getting the following error:
System.Data.SqlClient.SqlError: The operating system returned the error '5(Access is denied.)' while attempting 'RestoreContainer::ValidateTargetForCreation' on 'C:\Program Files\Microsoft SQL Server\MSSQL11.MSSQL11\MSSQL\datalab_auth.mdf'. (Microsoft.SqlServer.SmoExtended)
I tried to set the path in the above error to have permissions of Everyone to Full. Which it is currently set to.
What am I missing?
Upvotes: 2
Views: 450
Reputation: 3180
This worked for me. After you select your database to restore, select file option and check realocate all files to folder
Upvotes: 0
Reputation: 510
The OS error 5 is about to permissions issue on the files and folder paths, I have check my account on config manager to fix this issue. The fix steps on my case:
The environment is that, the OS is Win7 and the version of sql server is MS Sqlserver 2012
Upvotes: 0
Reputation: 32713
When you are performing a restore, make sure you set the option to "Overwrite the existing database" in the restore wizard.
Upvotes: 1
Reputation: 3929
Check what account you are using to run the SQL service through the SQL Configuration Manager and assign permissions to the account on the file and folder.
This post might help: mssql '5(Access is denied.)' error during restoring database
Upvotes: 0