Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to copy database with backup and restore database?
Message
From
25/02/2004 05:52:35
Jenny Karlsson
Megasol Technologies
Uppsala, Sweden
 
 
To
All
General information
Forum:
Microsoft SQL Server
Category:
Backups
Title:
How to copy database with backup and restore database?
Miscellaneous
Thread ID:
00880615
Message ID:
00880615
Views:
42
I just discovered a huge problem with my backup and restore script. We often need to create exact copies of databases under different names. The thing is we need exact copies not just allmost exact copies. Today I saw that this copy script I found in SQL Help not copy the idkeys (that are NEWID() uniqueidentifier) but are setting new idkeys.


USE master
GO
BACKUP DATABASE database_1
TO DISK = 'D:\Program Files\Microsoft SQL Server\MSSQL\BACKUP\database_1' WITH init
RESTORE FILELISTONLY
FROM DISK = 'D:\Program Files\Microsoft SQL Server\MSSQL\BACKUP\database_1'
RESTORE DATABASE database_2
FROM DISK = 'D:\Program Files\Microsoft SQL Server\MSSQL\BACKUP\database_1'
WITH MOVE 'database_1' TO 'D:\Program Files\Microsoft SQL Server\MSSQL\BACKUP\database_2.mdf',
MOVE 'database_1_log' TO 'D:\Program Files\Microsoft SQL Server\MSSQL\BACKUP\database_2.ldf'
GO


Can anybody see what's wrong? OR mayby give me an option how to create an exact copy of an existing database (on the same server). Thanks in advance!

Regards
Jenny
Next
Reply
Map
View

Click here to load this message in the networking platform