472,328 Members | 1,029 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

Restore a database to another server

Hi, i am using sql server 2000, and i make daily backups. I want to
restore my backup to a test msde database i have. I don't know how i
did it last time.

-The database name is the same: "web" on both places
-The database is located on different hard drives and the file name
are different on both places.

I tried to do it from enterprise manager, restore database, from
device, i chose the transaction file and the database backup itself
and tried to restore, but i got an error that i don't have exclusive
access to the database.

How can i fix this?
Nov 15 '07 #1
5 7240
Seguros Catatumbo (se**************@gmail.com) writes:
Hi, i am using sql server 2000, and i make daily backups. I want to
restore my backup to a test msde database i have. I don't know how i
did it last time.

-The database name is the same: "web" on both places
-The database is located on different hard drives and the file name
are different on both places.

I tried to do it from enterprise manager, restore database, from
device, i chose the transaction file and the database backup itself
and tried to restore, but i got an error that i don't have exclusive
access to the database.
RESTORE DATABASE db FROM DISK ='filenamehere'
WITH MOVE 'logicalname1' TO 'path.mdf',
MOVE 'logicalname2' TO 'path_log.ldf',
REPLACE

logicalname1/2 are the logical names of the device file. You find these
with help of sp_helpdb on the source database, or RESTORE FILELISTONLY
on the backup file.
--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinf...ons/books.mspx
Nov 15 '07 #2
RESTORE DATABASE db FROM DISK ='filenamehere'
WITH MOVE 'logicalname1' TO 'path.mdf',
MOVE 'logicalname2' TO 'path_log.ldf',
REPLACE
Hey Erland, thanks for replying. I couldn't get it to work. Here's the
command:

RESTORE DATABASE db FROM DISK ='c:\publica\web_db_200711150500.bak'
WITH MOVE 'WEB_Data' TO 'c:\pruebadb\web_dos.mdf',
MOVE 'WEB_Log' TO 'c:\pruebadb\web_dos_log.ldf',
REPLACE

Here's the error message:

The file 'c:\pruebadb\web_dos.mdf' cannot be overwritten. It is being
used by database 'web'.
File 'WEB_Data' cannot be restored to 'c:\pruebadb\web_dos.mdf'. Use
WITH MOVE to identify a valid location for the file.
The file 'c:\pruebadb\web_dos_log.ldf' cannot be overwritten. It is
being used by database 'web'.
File 'WEB_Log' cannot be restored to 'c:\pruebadb\web_dos_log.ldf'.
Use WITH MOVE to identify a valid location for the file.
RESTORE DATABASE is terminating abnormally.

Here's the output of sp_helpdb on the source db and destination db:

source:

WEB_Data
1 D:\DataWEB\Data
\web_Data.MDF
PRIMARY 4348096 KB Unlimited 5120 KB data only
WEB_Log
2 D:\DataWEB\Data
\web_Log.LDF
NULL 32448 KB Unlimited 10% log only
destination:

WEB_Data
1 C:\pruebadb
\web_dos.mdf
PRIMARY 2092928 KB Unlimited 5120 KB data only
WEB_Log
2 C:\pruebadb
\web_dos_log.ldf
NULL 1024 KB Unlimited 10% log only
The c:\publica\web_db_200711150500.bak was obtained from a backup made
by sql server itself on the source server itself
Nov 16 '07 #3
I made a mistake with the command. My database name is not db, it's
"web". So now i get the same error i get when i do with the GUI:

RESTORE DATABASE db FROM DISK ='c:\publica\web_db_200711150500.bak'
WITH MOVE 'WEB_Data' TO 'c:\pruebadb\web_dos.mdf',
MOVE 'WEB_Log' TO 'c:\pruebadb\web_dos_log.ldf',
REPLACE

Here's the error message:

Exclusive access could not be obtained because the database is in use.

Do i need to take the database offline or something?

Nov 16 '07 #4
Ok, i think i know how to fix it.

-WEB is my default database, so when i use query analizer it opens
that database. It can't restore the database if i am connected. So
instead of figuring off how to change the default database, i
connected, changed the current db to master (use master), and then i
could take web offline with enterprise manager. Now the command seems
to be working, it will take long, the database is 4GB.

RESTORE DATABASE web FROM DISK ='c:\publica\web_db_200711150500.bak'
WITH MOVE 'WEB_Data' TO 'c:\pruebadb\web_dos.mdf',
MOVE 'WEB_Log' TO 'c:\pruebadb\web_dos_log.ldf',
REPLACE
Nov 16 '07 #5
Yup, it worked, so the conclusion is that it would have worked from
the start if i just would have taken the database offline. Thanks for
your help

Nov 16 '07 #6

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

Similar topics

2
by: Sue Swanson | last post by:
Yesterday I received a response to my CI/CS Collation problem and the recommendation was to try and restore a CI Collation database to a CS...
1
by: xo55ox | last post by:
Hi, Did anyone successfully set up a local package to first ftp a db.bak and second perform an automated db restore? I need to perform an...
2
by: jbmccluskey | last post by:
I'm a newbie so please be gentle. In attempting to run a restore I get the following error message: "Exclusive access could not be obtained...
13
by: EggsAckley | last post by:
Hi: I have a file that I have been told is a SQL Server backup from a server somewhere. The file is about 200MB in size I am trying to create...
4
by: Rich | last post by:
Hi there, I've been sent a backup file from a SQL Server 2000 DB and tried restoring into a blank DB (with the same name) on my SQL Server 2K,...
1
by: CPNZ | last post by:
I have a database i am m oving to another server, during the process I am moving the data and log files to another drive.(Which I have done...
0
by: Takpol | last post by:
Hello, I have several archived filegroups that have data in them partitioned based on the date. These filegroups have been removed from database...
0
by: newman | last post by:
Dear all, I have mysql 4.1.11 on my current server, i need my database restore another server.. (another server mysql version is 4.1.11 same.) ...
6
by: javelin | last post by:
I'm having difficulty searching for an answer to this challenge. Can someone give me a clue on the right keywords to use to find a discussion on...
0
by: tammygombez | last post by:
Hey fellow JavaFX developers, I'm currently working on a project that involves using a ComboBox in JavaFX, and I've run into a bit of an issue....
0
by: tammygombez | last post by:
Hey everyone! I've been researching gaming laptops lately, and I must say, they can get pretty expensive. However, I've come across some great...
0
by: concettolabs | last post by:
In today's business world, businesses are increasingly turning to PowerApps to develop custom business applications. PowerApps is a powerful tool...
0
better678
by: better678 | last post by:
Question: Discuss your understanding of the Java platform. Is the statement "Java is interpreted" correct? Answer: Java is an object-oriented...
0
by: teenabhardwaj | last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
0
by: CD Tom | last post by:
This only shows up in access runtime. When a user select a report from my report menu when they close the report they get a menu I've called Add-ins...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
1
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...

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.