[dba-SQLServer] Duplicate a Database

Asger Blond ab-mi at post3.tele.dk
Mon Aug 4 12:41:46 CDT 2008


Dan,
One way is to make a backup followed by a restore using WITH MOVE - i.e.:

BACKUP DATABASE MyDatabase 
TO DISK='C:\MyBackupFolder\MyDatabase.bak'
GO
RESTORE DATABASE MyDuplicateDatabase 
FROM  DISK = 'C:\MyBackupFolder\MyDatabase.bak' 
WITH  MOVE 'MyDatabase_Data' 
TO 'C:\MyDataFolder\ MyDuplicateDatabase.mdf',  
MOVE 'MyDatabase_Log' TO 'C:\MyDataFolder\ MyDuplicateDatabase.ldf'
GO

Asger
-----Oprindelig meddelelse-----
Fra: dba-sqlserver-bounces at databaseadvisors.com
[mailto:dba-sqlserver-bounces at databaseadvisors.com] På vegne af Dan Waters
Sendt: 4. august 2008 18:45
Til: SQL Server List
Emne: [dba-SQLServer] Duplicate a Database

I'm using SQL Express, and have one database.  I'd like to duplicate that
database inside the same SQL instance and give the duplicate a different
name.

Within Management Studio, I can't see how to do that.

Is this possible?

Dan


_______________________________________________
dba-SQLServer mailing list
dba-SQLServer at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/dba-sqlserver
http://www.databaseadvisors.com






More information about the dba-SQLServer mailing list