If the db still exists, with the files in exactly the same locations as before (as shown in the FILELISTONLY output), and you want to restore over the current db, do this:
RESTORE DATABASE mydb
FROM DISK = 'c:\mydb7.7.2006.bak'
WITH REPLACE, RECOVERY
If the db does not exist, or you want to restore to a different name, do this:
RESTORE DATABASE mydb
FROM DISK = 'c:\mydb7.7.2006.bak'
WITH RECOVERY,
MOVE 'mydb_data' TO 'E:\Program Files\Miscrosoft SQL Server\MSSQL\mydb2.mdf', --<<-- chg physical file name as desired
MOVE 'mydb_Log' TO 'F:\SQL_logs\mydb2_log.ldf
As you'll recall, there is no requirement that the dataset name match the db name in any way; in fact you don't have to use the extensions .MDF and .LDF if you don't want to (although for recognizability and consistency it's certainly best to).
Main Topics
Browse All Topics





by: aneeshattingalPosted on 2006-07-10 at 09:00:11ID: 17074040
RESTORE FILELISTONLY
FROM DISK = 'c:\mydb7.7.2006.bak'
RESTORE DATABASE myDb
FROM DISK = 'c:\mydb7.7.2006.bak'
WITH MOVE 'myDb' TO 'E:\Program Files\Miscrosoft SQL Server\MSSQL\mydb.mdf',
MOVE 'myDb' TO 'F:\SQL_logs\mydb_log.ldf'
GO