I got Database file with .bak format and I need to import it to my SQL Server. When Restore Database there is an error: the operating system returned the error '5(access is denied.). Here are photos:
-
4Looks like you're restoring on a named instance (SQLMIKE), and trying to write the database files to the data folder of the default instance (MSSQLSERVER). Check the "Files" tab in the restore dialog and make sure you're writing to the correct location. – David Browne - Microsoft Jan 03 '21 at 17:18
-
The .bak file is from other person, so at first there was no database that is in the file. – MikeRyz Jan 04 '21 at 10:34
2 Answers
Thank you all for the comments. I found the answer here:
SQL Server Restore Error - Access is Denied
Relocate all files to folder should be checked in the 'Files' section: just like in the post. And here is photo:
Also, in the 'Options' section I checked the 'Overwrite the existing database(WITH REPLACE)' and after that it worked.

- 209
- 1
- 3
- 18
Your error message references the ClassNorthwind2_data.mdf
file. This is the actual database file and not a backup file.
There is not enough information in your question to identify where the failure has occurred - for example, what was the Device
that you selected that is blacked out on your image? Is this to the dame file? If so then you cannot restore from a mdf
file and you actually want to ATTACH
instead.
If you selected a BAK
file for the Device and the restore failed then do you already have a ClassNorthwind2
database on the instance? If so then you will need to go to the options tab and also select REPLACE so that it will try to overwrite the existing database.
To get a clear indication of what you selected you could click on the Script
option instead of clicking the button to restore and extract the actual T-SQL command which will make it more obvious what is going wrong.

- 1,714
- 1
- 6
- 18