Solved

Copy database

Posted on 2004-10-20
5
253 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Let's review the features of new SQL Server 2012 (Denali CTP3). It listed as below: PERCENT_RANK(): PERCENT_RANK() function will returns the percentage value of rank of the values among its group. PERCENT_RANK() function value always in be…
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
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.
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.

920 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

16 Experts available now in Live!

Get 1:1 Help Now