Reputation: 5056
I have a series of manual job:
.mdf
and .ldf
file locations.How can I do this? I've tried:
RESTORE DATABASE newdb
FROM DISK = 'F:\Shared\newdb.bak'
WITH MOVE 'newdb' TO 'G:\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\newdb.mdf',
MOVE 'newdb_log' TO 'G:\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\newdb_log.ldf',
replace
but I got:
Logical file 'newdb' is not part of database 'newdb'.
Use RESTORE FILELISTONLY to list the logical file names.
RESTORE DATABASE is terminating abnormally.
And if I use FILELISTONLY
I got another type of error:
Incorrect syntax near the keyword 'with'. If this statement is a common table expression or an xmlnamespaces clause, the previous statement must be terminated with a semicolon.
Upvotes: 0
Views: 1173
Reputation: 754220
You need to use find out the logical names using:
RESTORE FILELISTONLY
FROM DISK = 'F:\Shared\newdb.bak'
This gives you all the logical files contained in the backup, and their logical names.
With that information, you should be able to build up your RESTORE DATABASE
command properly.
See the relevant MSDN SQL Server Books Online documentation for more details.
Upvotes: 1