Solved

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

Posted on 2012-03-30
6
279 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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Join & Write a Comment

Everyone has problem when going to load data into Data warehouse (EDW). They all need to confirm that data quality is good but they don't no how to proceed. Microsoft has provided new task within SSIS 2008 called "Data Profiler Task". It solve th…
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.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

744 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

14 Experts available now in Live!

Get 1:1 Help Now