Solved

Copy database

Posted on 2004-10-20
5
281 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.

737 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