Check / grant SQL Server Service Account read and write permission for the folder.
Can't restore AdventeureWorksDW2022.bak
TITLE: Microsoft SQL Server Management Studio
Restore of database 'AdventureWorksDW2022' failed. (Microsoft.SqlServer.Management.RelationalEngineTasks)
ADDITIONAL INFORMATION:
Microsoft.Data.SqlClient.SqlError: The operating system returned the error '5(Access is denied.)' while attempting 'RestoreContainer::ValidateTargetForCreation' on 'C:\Program Files\Microsoft SQL Server\MSSQL16.MSSQLSERVER\MSSQL\DATA\AdventureWorksDW2022.mdf'. (Microsoft.SqlServer.Smo)
For help, click: https://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=17.100.40.0&LinkId=20476
BUTTONS:
OK
2 answers
Sort by: Most helpful
-
-
MikeyQiaoMSFT-0444 2,705 Reputation points
2024-08-27T06:03:11.9066667+00:00 Hi,Nada
Welcome to Microsoft Q&A fourm!
The issue may arise due to insufficient permissions for the folder, or the instance name not matching. You can try to fix this by granting the SQL user access permissions to the relevant directory. You can refer to the content in the following two links.
https://stackoverflow.com/questions/7031792/sql-server-restore-error-access-is-denied
https://www.stellarinfo.com/blog/fix-operating-system-error-5-access-is-denied-in-ms-sql-server
Regards
Mikey Qiao
If you're satisfied with the answer, don't forget to "Accept it," as this will help others who have similar questions to yours.