Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Administration (2000)
 Variable Name For Restore From Disk

Author  Topic 

chinkit
Starting Member

1 Post

Posted - 2007-12-13 : 02:54:54
The Code is as follows


use master
go
DECLARE @dbBackLoc varchar(1000)
SET @dbBackLoc = 'D:\Backup\Adminconfig.bak'

RESTORE DATABASE MaxConfiguration
FROM DISK = @dbBackLoc
WITH MOVE 'AdminConfig' TO 'E:\DATA\AdminConfig.mdf',
MOVE 'MaxConfiguration_Log' TO 'E:\LOG\AdminConfig_log.ldf',

REPLACE
==== ERROR =====

Msg 3201, Level 16, State 2, Line 4
Cannot open backup device 'C:\Program Files\Microsoft SQL Server\MSSQL.2\MSSQL\Backup\D:\Backup\Adminconfig.bak'. Operating system error 2(error not found).
Msg 3013, Level 16, State 1, Line 4
RESTORE DATABASE is terminating abnormally.


Where does the prefix to @dbBackLoc i.e "C:\Program Files\Microsoft SQL Server\MSSQL.2\MSSQL\Backup" come from ?

Any ideas & help much appreciated.

Cheers!

RickD
Slow But Sure Yak Herding Master

3608 Posts

Posted - 2007-12-13 : 03:58:40
That will be your default restore directory, this will be used as at compile time, the statement doesn't think you have specified a location for the restore. If you want to run a restore this way, I think you will need to use dynamic sql to build your restore string and then exec it.
Go to Top of Page

jen
Master Smack Fu Yak Hacker

4110 Posts

Posted - 2007-12-13 : 11:30:43
is D: local? if no... use mapped drives or unc path

--------------------
keeping it simple...
Go to Top of Page
   

- Advertisement -