Solved

Copy database

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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Performance is the key factor for any successful data integration project, knowing the type of transformation that you’re using is the first step on optimizing the SSIS flow performance, by utilizing the correct transformation or the design alternat…
Nowadays, some of developer are too much worried about data. Who is using data, who is updating it etc. etc. Because, data is more costlier in term of money and information. So security of data is focusing concern in days. Lets' understand the Au…
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…
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed

707 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

13 Experts available now in Live!

Get 1:1 Help Now