Solved

How to restore SQL Server dump file

Posted on 2004-04-02
3
17,025 Views
Last Modified: 2007-12-19
Hi Guru:

I work with Oracle but is completedly new to SQL Server. I was required to create database and restore from a dump file (I would think that it likes oracle's import). The dump file was created by SQL Server's backup command(I would think it likes oracle's export). But I got errors like:

Server: Msg 5105, Level 16, State 2, Line 3
Device activation error. The physical file name 'C:\Program Files\Microsoft SQL Server\MSSQL\data\dev_Data.MDF' may be incorrect.
Server: Msg 3156, Level 16, State 1, Line 3
File 'vwdev_Data' cannot be restored to 'C:\Program Files\Microsoft SQL Server\MSSQL\data\dev_Data.MDF'. Use WITH MOVE to identify a valid location for the file.
Server: Msg 5105, Level 16, State 1, Line 3

I use the command as:

restore database  dev
from disk = 'C:\TEMP\James\dev.bak'
go

Any suggestions, thanks.
0
Comment
Question by:http29
3 Comments
 
LVL 7

Accepted Solution

by:
ChrisFretwell earned 100 total points
ID: 10746304
run this command first. It gives you the details of what you need to know about that backup.

restore filelistonly from disk = 'c:\temp\james\dev.bak'

this will tell you about the mdf and ldf and their logical names. then you can run the restore with move.

it sounds like you want to restore to somewhere other than where the original was. for this you need to use with move like this

move '[logical_file_name]' to '[operating_system_file_name]'

so based on what your filelistonly shows you, you can

restore database dev
from disk = 'c:\temp\james\dev.bak'
with move 'dev' to 'c:\dev_data.mdf',
move 'dev_log' to 'c:\dev_log.ldf'

Chris
0
 
LVL 34

Expert Comment

by:arbert
ID: 10746393
Agree with chris--if you're restoring to a different directory structure, you're going to have to use MOVE...TO.  Also, if the directory structure is the same and you're restoring over an existing database, you need to use the WITH REPLACE option.

Brett
0
 
LVL 42

Expert Comment

by:EugeneZ
ID: 10759729
just one thing:
logical name is not alwayse like databse name - looks like (from error above) you have not 'dev' but 'vwdev_Data'
for dat file:

restore database dev            
from disk = 'c:\temp\james\dev.bak'
with move 'vwdev_Data' ' to 'c:\dev_data.mdf',
move 'dev_log' to 'c:\dev_log.ldf'   ---

--to see logical name of the dtabase - run in Query Analyzer -
use yourdatabsenamesource
go
select name,filename  from sysfiles
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Introduction SQL Server Integration Services can read XML files, that’s known by every BI developer.  (If you didn’t, don’t worry, I’m aiming this article at newcomers as well.) But how far can you go?  When does the XML Source component become …
Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.

825 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