Solved

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

Posted on 2012-03-30
6
286 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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

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.
In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL 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.

776 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