Question

trying to restore .bak with SQL Server Management Studio

Asked by: hologos2357

I have a file located at c:\mydb.7.7.2006.bak.  I need to restore it to a location on my local computer running win xp with sql express.  

Here is what I have done:

restore filelistonly
from disk = 'c:\mydb7.7.2006.bak'

Here are the physical paths in the result:
Physical Name - mydb_data: E:\Program Files\Miscrosoft SQL Server\MSSQL\mydb.mdf
Physical Name - mydb_Log: F:\SQL_logs\mydb_log.ldf

Using this info, can someone tell me how to restore the .bak?

Thanks in advance.


This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2006-07-10 at 08:57:01ID21913916
Tags

sql

,

restore

,

server

Topics

MS SQL Server

,

Adobe Type Manager

Participating Experts
3
Points
500
Comments
16

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. restore database from .bak
    would like to work on a website with local host, using SQL 2005, have .bak file, RESTORE DATABASE CAIN FROM DISK='C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Backup\Cain.bak' WITH RECOVERY, REPLACE, MOVE 'Cain_data' TO 'C:\Program Files\Microsoft SQL Server\MSSQL.1\MS...
  2. delete bak file
    i am using this script below, i need it to delete the bak file when it has restored the db
  3. mssql .bak
    Hi, I have a .bak file of 4 gb... I am using mssql 2008 ------180 days version. When i tried to reatore a back up file and select the file(4gb) i have it shows me error.Tell that some 4098 is the maximum amount ... Can anyone Solve this?
  4. .bak files
    I have located a few .bak files which I beleive are backups of SQL Server Databases? In a secure offline environment, which tools (free if preferable) can be used to restore these files to see what data was in them? Does the .bak come with any security features, i.e. if we r...
  5. Database Restore from .bak file
    Hi, I have a backup file from an old server which has sql server 2005 database on it on to new server in c folder. I created a empty database like this USE [master] GO /****** Object: Database [Wind] Script Date: 08/19/2010 11:46:02 ******/ CREATE DATABASE [Wind] ON PRIM...

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: aneeshattingalPosted on 2006-07-10 at 09:00:11ID: 17074040

RESTORE FILELISTONLY
   FROM DISK = 'c:\mydb7.7.2006.bak'
RESTORE DATABASE myDb
   FROM DISK = 'c:\mydb7.7.2006.bak'
   WITH MOVE 'myDb' TO 'E:\Program Files\Miscrosoft SQL Server\MSSQL\mydb.mdf',
   MOVE 'myDb' TO 'F:\SQL_logs\mydb_log.ldf'
GO

 

by: ScottPletcherPosted on 2006-07-10 at 09:08:53ID: 17074138

If the db still exists, with the files in exactly the same locations as before (as shown in the FILELISTONLY output), and you want to restore over the current db, do this:

RESTORE DATABASE mydb
FROM DISK = 'c:\mydb7.7.2006.bak'
WITH REPLACE, RECOVERY


If the db does not exist, or you want to restore to a different name, do this:

RESTORE DATABASE mydb
FROM DISK = 'c:\mydb7.7.2006.bak'
WITH RECOVERY,
    MOVE 'mydb_data' TO 'E:\Program Files\Miscrosoft SQL Server\MSSQL\mydb2.mdf',  --<<-- chg physical file name as desired
    MOVE 'mydb_Log' TO 'F:\SQL_logs\mydb2_log.ldf'  --<<-- chg physical file name as desired


As you'll recall, there is no requirement that the dataset name match the db name in any way; in fact you don't have to use the extensions .MDF and .LDF if you don't want to (although for recognizability and consistency it's certainly best to).

 

by: hologos2357Posted on 2006-07-10 at 09:30:14ID: 17074377

Thanks, both.  I get errors with each solution.  Do I need to create a blank SQL db over which I restore the .bak?  I don't have the original db on my local.

aneeshattingal -

I get the following error:
Msg 3234, Level 16, State 2, Line 3
Logical file 'mydb' is not part of database 'mydb'. Use RESTORE FILELISTONLY to list the logical file names.
Msg 3013, Level 16, State 1, Line 3
RESTORE DATABASE is terminating abnormally.

ScottPletcher-

I get the following error using the second solution:
Msg 5133, Level 16, State 1, Line 1
Directory lookup for the file "E:\Program Files\Miscrosoft SQL Server\MSSQL\mydb2.mdf" failed with the operating system error 3(The system cannot find the path specified.).
Msg 3156, Level 16, State 3, Line 1
File 'mydb_Data' cannot be restored to 'E:\Program Files\Miscrosoft SQL Server\MSSQL\mydb2.mdf'. Use WITH MOVE to identify a valid location for the file.
Msg 5133, Level 16, State 1, Line 1
Directory lookup for the file "F:\SQL_logs\mydb2_log.ldf" failed with the operating system error 3(The system cannot find the path specified.).
Msg 3156, Level 16, State 3, Line 1
File 'mydb_Log' cannot be restored to 'F:\SQL_logs\mydb2_log.ldf'. Use WITH MOVE to identify a valid location for the file.
Msg 3119, Level 16, State 1, Line 1
Problems were identified while planning for the RESTORE statement. Previous messages provide details.
Msg 3013, Level 16, State 1, Line 1
RESTORE DATABASE is terminating abnormally.

 

by: aneeshattingalPosted on 2006-07-10 at 09:37:32ID: 17074462

Run

RESTORE FILELISTONLY
FROM DISK =  'c:\mydb7.7.2006.bak'


and find the ouput

 

by: hologos2357Posted on 2006-07-10 at 09:42:49ID: 17074522

Hard to copy/paste, but here is all of it:

mydb_Data      E:\Program Files\Microsoft SQL Server\MSSQL\Data\mydb.mdf      D      PRIMARY      148111360      330301440      1      0      0      00000000-0000-0000-0000-000000000000      0      0      0      512      1      NULL      34788000000026900007      EB29180A-84E2-4330-B757-675CAEA7EC03      0      1
mydb_Log      F:\SQL_logs\mydb_log.ldf      L      NULL      2359296      314572800      2      0      0      00000000-0000-0000-0000-000000000000      0      0      0      512      0      NULL      0      00000000-0000-0000-0000-000000000000      0      0

 

by: ScottPletcherPosted on 2006-07-10 at 09:44:26ID: 17074541

Oh, right, probably the current machine has only a c: drive (?).  If so, and there is space available on the c: drive to restore it, try this:


RESTORE DATABASE mydb
FROM DISK = 'c:\mydb7.7.2006.bak'
WITH RECOVERY,
    MOVE 'mydb_data' TO 'C:\mydb.mdf',
    MOVE 'mydb_Log' TO 'C:\mydb_log.ldf'

 

by: hologos2357Posted on 2006-07-10 at 09:47:30ID: 17074570

Yes, only  a C drive.  I tried the above and got this error:
Msg 3634, Level 16, State 1, Line 1
The operating system returned the error '5(Access is denied.)' while attempting 'RestoreContainer::ValidateTargetForCreation' on 'C:\mydb.mdf'.
Msg 3156, Level 16, State 5, Line 1
File 'mydb_Data' cannot be restored to 'C:\mydb.mdf'. Use WITH MOVE to identify a valid location for the file.
Msg 3634, Level 16, State 1, Line 1
The operating system returned the error '5(Access is denied.)' while attempting 'RestoreContainer::ValidateTargetForCreation' on 'C:\mydb_log.ldf'.
Msg 3156, Level 16, State 5, Line 1
File 'mydb_Log' cannot be restored to 'C:\mydb_log.ldf'. Use WITH MOVE to identify a valid location for the file.
Msg 3119, Level 16, State 1, Line 1
Problems were identified while planning for the RESTORE statement. Previous messages provide details.
Msg 3013, Level 16, State 1, Line 1
RESTORE DATABASE is terminating abnormally.

 

by: aneeshattingalPosted on 2006-07-10 at 09:49:19ID: 17074589

hologos2357,

RESTORE DATABASE myDb
   FROM DISK = 'c:\mydb7.7.2006.bak'
   WITH MOVE 'myDb' TO 'C:\mydb.mdf',
   MOVE 'myDb' TO 'C:\mydb_log.ldf'
GO

 

by: ScottPletcherPosted on 2006-07-10 at 09:54:07ID: 17074637

Odd, looks like you -- that is, the id under which the command was running -- didn't have authority to write to the drive.  Is there a directory path you do have authority to write to?  If so, change the restore to point to that location:

RESTORE DATABASE mydb
FROM DISK = 'c:\mydb7.7.2006.bak'
WITH RECOVERY,
    MOVE 'mydb_data' TO 'C:\pathICanWriteTo\mydb.mdf',
    MOVE 'mydb_Log' TO 'C:\pathICanWriteTo\mydb_log.ldf'

 

by: hologos2357Posted on 2006-07-10 at 10:41:13ID: 17075048

Aneeschattingal-

I get the following error:
Msg 3234, Level 16, State 2, Line 1
Logical file 'mydb' is not part of database 'mydb'. Use RESTORE FILELISTONLY to list the logical file names.
Msg 3013, Level 16, State 1, Line 1
RESTORE DATABASE is terminating abnormally.

ScottPletcher-
How do I change permissions to get authority to write to the drive?  I would think I already have it, but maybe I need to enable myself?

Thanks!

 

by: ScottPletcherPosted on 2006-07-10 at 10:44:55ID: 17075078

If you don't have authority to the drive, you probably don't have authority to give yourself that authority :-) .

You would need a Windows admin to grant you at least full authority to the C:\ drive, and even more permissions might be helpful to what you want to do.

 

by: hologos2357Posted on 2006-07-10 at 11:14:58ID: 17075389

Hmm, well this is my computer, and I am the only one who uses it.  I can't see why I couldn't write to my own drive?  Am I missing something here?  Do I need to call MS and get some licensing code?  I am using the free SQL express.  Will this not do the trick?

Thanks,
James

 

by: ScottPletcherPosted on 2006-07-10 at 11:19:02ID: 17075440

Do you have full admin rights in SQL?

Does the SQL id have full admin rights to Windows / other resources?

[These qs may not apply to Express version; I haven't used it.]

 

by: hologos2357Posted on 2006-07-10 at 18:34:21ID: 17078277

Sorry, but I can't figure out how to determine if I have access or not.  During setup, I chose to use my Windows Authentication (I just reinstalled sql express plus the trial version of 2005).  How do I find out if I have full admin rights in sql, and how do I find out if the sql id has full adminr rights to windows?

Thanks!

 

by: imran_fastPosted on 2006-07-11 at 05:23:13ID: 17080781

>>Sorry, but I can't figure out how to determine if I have access or not.
On your machine go to start --> programfiles --> microsoft sql server 2005 --> configuration tools sql server configuration manager
user services check mssql server and check the log on tab and see what is the user there and give him full privellages on the system if it is local then the user u have used to login to the server should be admin.

and then
use this  scotts suggestion
RESTORE DATABASE mydb
FROM DISK = 'c:\mydb7.7.2006.bak'
WITH RECOVERY,
    MOVE 'mydb_data' TO 'C:\mydb.mdf',
    MOVE 'mydb_Log' TO 'C:\mydb_log.ldf'



 

by: hologos2357Posted on 2006-07-11 at 06:49:26ID: 17081439

Imran__fast-
Thanks.  I changed the user from Network Service to Local Service and this did the trick.  

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...