Solved

How to restore SQL Server dump file

Posted on 2004-04-02
3
17,010 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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
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…
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.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

705 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now