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)
 Restoring Database

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2004-09-14 : 08:23:16
Ron Neville writes "Hi there,
Thanks for the excellent site adn opportunity to ask you guys a question.

I have a backup of a SQL DB which has the table structure I need for my DB.

Could you please tell me how I can restore this DB. I have been working with SQL for a couple of years but can't crack this...

THank you for any assistance... Ron Neville"

jen
Master Smack Fu Yak Hacker

4110 Posts

Posted - 2004-09-14 : 08:31:46
what's your actual problem? are you encountering some errors? if yes can you share them with us so someone here can provide you some clear answers?
Go to Top of Page

derrickleggett
Pointy Haired Yak DBA

4184 Posts

Posted - 2004-09-14 : 08:38:33
From Books Online:


How to restore a database with a new name (Transact-SQL)
To restore a database with a new name

Optionally, execute the RESTORE FILELISTONLY statement to determine the number and names of the files in the database backup.


Execute the RESTORE DATABASE statement to restore the database backup, specifying:
The new name for the database.


The backup device from where the database backup will be restored.


The NORECOVERY clause if you have transaction log backups to apply after the file backups are restored. Otherwise, specify the RECOVERY clause.
The transaction log backups, if applied, must cover the time when the files were backed up.

The MOVE clause for each file to restore to a new location if the file names already exist. For example, creating a copy of an existing database on the same server for testing purposes may be necessary. In this case, the database files for the original database already exist, and so different file names need to be specified when the database copy is created during the restore operation.
Examples
This example creates a new database called MyNwind2_Test. MyNwind2_Test is a copy of the existing MyNwind2 database that comprises two files: MyNwind2_data and MyNwind2_log. Because the MyNwind2 database already exists, the files in the backup need to be moved during the restore operation. The RESTORE FILELISTONLY statement is used to determine the number and names of the files in the database being restored.

USE master
GO
-- First determine the number and names of the files in the backup.
-- MyNwind_2 is the name of the backup device.
RESTORE FILELISTONLY
FROM MyNwind_2
-- Restore the files for MyNwind2_Test.
RESTORE DATABASE MyNwind2_Test
FROM MyNwind_2
WITH RECOVERY,
MOVE 'MyNwind2_data' TO 'D:\MyData\MyNwind2_Test_data.mdf',
MOVE 'MyNwind2_log' TO 'D:\MyData\MyNwind2_Test_log.ldf'
GO


See Also

RESTORE

Copying Databases

©1988-2004 Microsoft Corporation. All Rights Reserved.


MeanOldDBA
derrickleggett@hotmail.com

When life gives you a lemon, fire the DBA.
Go to Top of Page
   

- Advertisement -