Solved

What's the fastest way to copy a database on the same server?

Posted on 2012-03-30
6
282 Views
Last Modified: 2012-04-14
If I want to copy a database test_db1 to a same database server with a different name test_db2, what would be the fast way to do it?

Can I use features like Log Shipping or Transactional Replication on the same database server?

Thanks.
0
Comment
Question by:thomaszhwang
6 Comments
 
LVL 25

Accepted Solution

by:
TempDBA earned 125 total points
ID: 37788229
Backup the database and restore it with different name. That is the easiest and fastest way I guess.
0
 

Author Comment

by:thomaszhwang
ID: 37788391
Can I specify a different database file path when I restore, since if the original database is still there, you cannot just restore the database without specifying a new file path, right?  If so, what T-SQL command should I use?  Thanks.
0
 
LVL 23

Assisted Solution

by:Racim BOUDJAKDJI
Racim BOUDJAKDJI earned 250 total points
ID: 37789478
<<Can I specify a different database file path when I restore, since if the original database is still there>>
when restoring forget about the old database files and old database.  Simply restore the new database with a new name and use the WITH MOVE instruction to assign a new name for the files...For more info,read the below link on how using RESTORE DATABASE instruction WITH MOVE option...

http://msdn.microsoft.com/en-us/library/ms186858.aspx
0
Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

 
LVL 23

Assisted Solution

by:Racim BOUDJAKDJI
Racim BOUDJAKDJI earned 250 total points
ID: 37789483
<<Can I use features like Log Shipping or Transactional Replication on the same database server?>>
Yes.  But it has little or no value.  If you want to keep a READ ONLY copy you can use database snapshots
0
 
LVL 32

Assisted Solution

by:bhess1
bhess1 earned 125 total points
ID: 37789682
A generalized restore statement for a simple database backup with only one data file and one log file involved would be like this:

RESTORE DATABASE MyTestDB
FROM DISK='X:\Backups\MyDB.BAK'
WITH Recovery, Replace,
MOVE 'MyDB_data' TO 'X:\SQLData\MyTestDB.mdf',
MOVE 'MyDB_log' TO 'X:\SQLLogs\MyTestLog.ldf',

Where:
MyTestDB is the new database name to use
DISK='...' is the physical location of the backup file on disk
WITH x is the list of options to use - Recovery, Replace is my personal standard pair.  See BoL for more info
MOVE definition
'MyDB_x' is the logical filename being discussed.  Logical filenames can be recovered by executing RESTORE FILELISTONLY from DISK='...'
TO '...' is the physical destination and filename to be used.  You can restore to the same physical location as the original files are in if you rename the resulting files.
0
 

Author Closing Comment

by:thomaszhwang
ID: 37847503
Thanks.
0

Featured Post

[Webinar] Disaster Recovery and Cloud Management

Learn from Unigma and CloudBerry industry veterans which providers are best for certain use cases and how to lower cloud costs, how to grow your Managed Services practice in IaaS clouds, and how to utilize public cloud for Disaster Recovery

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
How to leverage one TLS certificate to encrypt Microsoft SQL traffic and Remote Desktop Services, versus creating multiple tickets for the same server.
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now