News

Copyright © 2008-2018 Paula DiTallo

Tag Cloud



SQL Server: Restoring a backup generates this error: Operating system error 5(Access is denied.).

There are several reasons for this. The most common reason is that the account you are using while logged into mssql through ssms does not have access to the drive definition you are using as your source. Network drives are a good example of an access conflict.

Assuming you have access to the drive, try redirecting the network drive to a local drive letter via xp_cmdshell  (Note: be sure use of xp_cmdshell is enabled) .

exec master..xp_cmdshell 'net use Z: "\\BackupServerXX\<share>\PathWithoutTrailingSlash" YourADpasswordHere /user:domain\your.Username'
Declare @restorefile varchar(1024) = 'Z:\thebackupfile.bak'
Restore database x
From disk = @restoreFile


When you are done, or if you've made a mistake and need to reassign the drive, delete the reference.

exec master..xp_cmdshell 'net use Z: /delete'
Thursday, June 26, 2014 3:32 PM

Feedback

No comments posted yet.


Post A Comment
Title:
Name:
Email:
Comment:
Verification: