Solved

Copy database

Posted on 2004-10-20
5
270 Views
Last Modified: 2008-03-17
I need to make a complete copy of entire database and use it under different name on the same server.
How can I do it on MS SQL 2000?
0
Comment
Question by:glowas
5 Comments
 
LVL 9

Expert Comment

by:apirnia
ID: 12360001
The best way to do this is first take a backup of a Database and then restore it.

The secound way which sometimes could raise some errors is to use DTS packagae.
0
 

Author Comment

by:glowas
ID: 12360022
I can restore it to the same database but not to second copy on the same server, that is my problem....
0
 
LVL 9

Accepted Solution

by:
apirnia earned 500 total points
ID: 12360089
This is what you have to do.

Create your new database. Right Click >> New Database....
Then right click on the database >> All task >> Restore
On this page you see 3 radio buttons. Select the 3rd one "From Device"

on this page click on the button "Select Device" and then "ADD"
Browse to your back up file. and then click OK

No on the first window select the options Tab
and clcik on Force restore Over existing database.

This should do
0
 
LVL 32

Expert Comment

by:bhess1
ID: 12360215
You can also use the RESTORE DATABASE SQL command, like this:

RESTORE DATABASE MyDB2
FROM Disk='E:\BackupSQL\mybackup.dat'
WITH Recovery, Replace,
MOVE 'MyDB_Data' TO 'E:\SQLSrvr\Primary\MyDB2\MyDB_DATA.MDF',
MOVE 'MyDB_Log' TO 'D:\SQLSrvr\TranLog\MyDB2\MyDB_LOG.LDF'

Notes:
   The MOVE command is **important**.  You **must** move the .MDF and .LDF files to a location different from the original files.

We use this type of command to update a static DB.  Backup DB, restore to new location, update new DB, rewrite pointer so all calls go to 2nd location, repeat nightly.
0
 
LVL 5

Expert Comment

by:MichaelSFuller
ID: 12361554
A quicker and less painfull method...

1) Stop SQL Server
2) Make a copy of the physical files, to another location
3) In Enterprise Manager select the databases node
4) Right Click -->All Tasks--> attach database
5) Find the file location you made a copy of the physical files
6) Put the name you would like to call it in the "Attach as"
7) Click OK

or

net stop SQLSERVERAGENT
net stop MSSQLSERVER


copy source.mdf destination.mdf
copy source.ldf destination.ldf

osql /E /S Servername /Q "sp_attach_db @dbname = N'yournewdatabasename',
   @filename1 = N'c:\Program Files\Microsoft SQL Server\MSSQL\Data\yourdatabase_data.mdf',
   @filename2 = N'c:\Program Files\Microsoft SQL Server\MSSQL\Data\yourdatabase_log.ldf'"

net start MSSQLSERVER
net start SQLSERVERAGENT

If you attached this to another instance you would have problems with orphaned users. This can be resolved rather easily though.
0

Featured Post

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

Introduction SQL Server Integration Services can read XML files, that’s known by every BI developer.  (If you didn’t, don’t worry, I’m aiming this article at newcomers as well.) But how far can you go?  When does the XML Source component become …
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
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 extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.

839 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