Solved

How to restore SQL Server dump file

Posted on 2004-04-02
3
17,036 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:Eugene Z
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

Edgartown IT Case Study

Learn about Edgartown's quest to ensure the safety and security of the entire town's employee and citizen data. Read the case study!

Question has a verified solution.

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

Let's review the features of new SQL Server 2012 (Denali CTP3). It listed as below: PERCENT_RANK(): PERCENT_RANK() function will returns the percentage value of rank of the values among its group. PERCENT_RANK() function value always in be…
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
Viewers will learn how the fundamental information of how to create a table.

735 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