Monday, February 13, 2012

Copy sql server 2005 database on the same machine

How can I create a copy of an existing sql server 2005 (live or offline) database and put it on the same server in a test database ?

First, make a Backup.

Then, look in Books Online about using RESTORE ... WITH MOVE.

Example:

Code Snippet


BACKUP DATABASE Northwind
TO DISK = 'c:\Northwind.bak'

RESTORE DATABASE TestDB
FROM DISK = 'c:\Northwind.bak'
WITH MOVE 'Northwind' TO 'c:\test\testdb.mdf',
MOVE 'Northwind_log' TO 'c:\test\testdb.ldf'

|||Thanks for the reply. Your response was very helpful.

No comments:

Post a Comment