Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Copy database

Posted on 2004-10-20
5
Medium Priority
?
297 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 2000 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:Brendt Hess
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

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

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

Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
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.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

610 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