473,396 Members | 2,140 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

How do I copy a database

I want to take a copy of a database, and mail it to another sql-server, and
then get it up and running.

I normally detach it, and copy the .MDF. But there are users using the
database, so that option is out.

I checked out the copy database wizard, but it can't copy it to the same
sql-server.

I checked out the back-up wizard. It takes a backup ok, but what do I do
with the .BAK file ? I can't rename it to .MDF and attach it on the other
server.

newbie thx from,
/jim
Jul 20 '05 #1
2 4268

"Jim Andersen" <jimVÆÆK@officeconsult.dk> wrote in message
news:40**********************@news.sunsite.dk...
I want to take a copy of a database, and mail it to another sql-server, and then get it up and running.

I normally detach it, and copy the .MDF. But there are users using the
database, so that option is out.

I checked out the copy database wizard, but it can't copy it to the same
sql-server.

I checked out the back-up wizard. It takes a backup ok, but what do I do
with the .BAK file ? I can't rename it to .MDF and attach it on the other
server.

Restore it.

RESTORE DATABASE FOO from disk='d:\myback.BAK'

Check out the WITH MOVE option also.

And RESTORE FILELISTONLY from disk='d:\myback.BAK' may be useful.

newbie thx from,
/jim

Jul 20 '05 #2
Jim Andersen (jimVÆÆK@officeconsult.dk) writes:
I checked out the back-up wizard. It takes a backup ok, but what do I do
with the .BAK file ? I can't rename it to .MDF and attach it on the other
server.


First sp_helpdb on the database, take note of the logical filenames.
(You can also retrieve this with RESTORE FILELISTONLY.)

Then:

RESTORE DATABASE some_db FROM disk = 'C:\dump-in-the-mail.bak'
WITH MOVE 'some_db' TO 'C:\MSSQL\Data\some_db.mdf',
MOVE 'some_db_log' TO 'D:\MSSQL\Logs\some_db.ldf',
REPLACE

Replace all names and locations to what applies to your case.


--
Erland Sommarskog, SQL Server MVP, so****@algonet.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Catherine Jo Morgan | last post by:
I get the point of backing up the database I'm working on, but what's a prototype copy? How do I make one and why is it important to work on that rather than on the main database? Or is this more...
7
by: lgbjr | last post by:
Hello All, I¡¯m using a context menu associated with some pictureboxes to provide copy/paste functionality. Copying the image to the clipboard was easy. But pasting an image from the clipboard...
1
by: Rachel McConnell | last post by:
Hi, I am trying to import data using COPY, from a file containing thirty or so COPY commands each with 0 or more rows of data. Reason, I have a small data set I want to include into a database...
4
by: JIM.H. | last post by:
Hello, I am trying to write the data I got from a web service to my table in SQL Server I need to append the dataset wsDS to the dataset ds and do update. PVS.myWS.Loader load = new...
5
by: Steve | last post by:
Hi; I thought I would rephrase a question I asked in another post to more quickly get to the heart of the matter. My apologies for anyone who is offended by what appears to be a repetition. ...
2
by: miroku800 | last post by:
A little history I designed a program in VB6 which used an access database with the aid of a then workmate (who has now moved on and lost interest) which was in two parts. A master program and a...
1
by: Scott Gifford | last post by:
Hello, I'm working on an providing an iterator interface to a database. The basic thing I'm trying to accomplish is to have my iterator read rows from the database and return constructed...
8
by: Abandoned | last post by:
Hi. I want to copy my database but python give me error when i use this command. cursor.execute("pg_dump mydata old.dump") What is the problem ? And how can i copy the database with python ?...
1
by: ll | last post by:
Hi, I have copied a MS SQL database to my local machine and am testing it with ASP pages, locally, on IIS. I have a db connect page that keeps the current connections for the live database. My...
1
by: Coni | last post by:
Hello, I am following steps to implement security on access 2003 through distribution: I have split the database and I am trying to distribute it: I have copied the back end file and...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.