Re: Database copy
- From: Erland Sommarskog <esquel@xxxxxxxxxxxxx>
- Date: Fri, 9 Nov 2007 22:24:20 +0000 (UTC)
Marcos (marcos_rodas@xxxxxxxxxxx) writes:
I guess I'll need a script to restore the database then drop the users.
Are this the commands I need to restore the database?
RESTORE DATABASE database_name
FROM DISK = 'C:\Backups\database_name.BAK'
WITH NORECOVERY
Depends. Only use WITH NORECOVERY if you intend to also restore
transaction logs. Which you usually don't want when you copy a database.
Also, when you copy a database to different locations or different
names, SQL Server can be picky about details, leading to this
command:
RESTORE DATABASE db
FROM DISK = 'backuppath'
WITH MOVE 'logicalname1' TO 'phyiscalpath1',
MOVE 'logicalname2' TO 'physicalpath2',
REPLACE
The logical names are the internal names of the database files, and
you can find then with sp_helpdb to RESTORE FILELISTONLY.
physicalpath1 is the place for the files of the restored database.
--
Erland Sommarskog, SQL Server MVP, esquel@xxxxxxxxxxxxx
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx
.
- Follow-Ups:
- Re: Database copy
- From: Marcos
- Re: Database copy
- References:
- Database copy
- From: msnews
- Re: Database copy
- From: Erland Sommarskog
- Re: Database copy
- From: msnews
- Re: Database copy
- From: Erland Sommarskog
- Re: Database copy
- From: Marcos
- Database copy
- Prev by Date: Re: Database copy
- Next by Date: Re: advanced editor
- Previous by thread: Re: Database copy
- Next by thread: Re: Database copy
- Index(es):
Relevant Pages
|