开发者

SQL Server Restore using T-SQL - error '5(error not found)'

开发者 https://www.devze.com 2023-01-29 13:02 出处:网络
To restore a database data and log files to different drives I am running the following T-SQL: RESTORE DATABASE DbName_BLAH

To restore a database data and log files to different drives I am running the following T-SQL:

RESTORE DATABASE DbName_BLAH
FROM DISK = 'w:\temp\DbName.bak'
WITH MOVE 'DbName' TO 'm:\DbName_BLAH.mdf',
MOVE 'DbName_log' TO 'l:开发者_开发技巧\DbName_BLAH_log.ldf'

And receiving the following errors:

Msg 3634, Level 16, State 1, Line 16 The operating system returned the error '5(error not found)' while attempting 'RestoreContainer::ValidateTargetForCreation' on 'm:\DbName_BLAH.mdf'. Msg 3156, Level 16, State 5, Line 16 File 'DbName' cannot be restored to 'm:\DbName_BLAH.mdf'. Use WITH MOVE to identify a valid location for the file. Msg 3634, Level 16, State 1, Line 16 The operating system returned the error '5(error not found)' while attempting 'RestoreContainer::ValidateTargetForCreation' on 'l:\DbName_BLAH_log.ldf'. Msg 3156, Level 16, State 5, Line 16 File 'DbName_log' cannot be restored to 'l:\DbName_BLAH_log.ldf'. Use WITH MOVE to identify a valid location for the file. Msg 3119, Level 16, State 1, Line 16 Problems were identified while planning for the RESTORE statement. Previous messages provide details. Msg 3013, Level 16, State 1, Line 16 RESTORE DATABASE is terminating abnormally.

The database restores as expected when I execute:

RESTORE DATABASE DbName_BLAH
FROM DISK = 'w:\temp\DbName.bak'
WITH MOVE 'DbName' TO 'w:\temp\DB_BLAH.mdf',
MOVE 'DbName_log' TO 'w:\temp\DbName_BLAH_log.ldf'

I have checked permissions on M: and L:. Any ideas?

UPDATE: Permissions were given to the SQL Server login rather than the SQL Server service account. See answer below.


Verify that the account that SQL Server is running under has access to these L:\ and M:\ paths.

0

精彩评论

暂无评论...
验证码 换一张
取 消