Solved

How to restore a database

Posted on 2013-11-21
5
200 Views
Last Modified: 2013-12-05
Trying to migrate an SQL database to a different server computer. I have backed up the database to a .bak file. When I try to restore, in the new SQL server (microsoft) it asks for which database to restore to. Do I create a blank database first? And should the blank database be the same name as the old one?
0
Comment
Question by:bobox00
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 12

Expert Comment

by:Tony303
ID: 39667038
You don't need to create a new Db first.
You can restore it from the backup file you are using, you can rename the DB here too if you wish.

Check the path of the ldf and mdf file locations, are they the correct place for your log and data files on your server you are restoring on?

The last part is important too.
Goto the options tab (I am presuming you are using SSMS to do all this), and select the "leave database ready to use...." radio button.

Tony.
0
 
LVL 9

Expert Comment

by:QuinnDex
ID: 39667089
it is much easier just to create a blank DB you can name it what you want and then restore to that...
0
 
LVL 27

Accepted Solution

by:
Zberteoc earned 500 total points
ID: 39667158
Either way you will have to map the .mdf data file and .ldf log file over to the new locations on the new server.

If the database doesn't exist on the target server, in the destination text box in the restore window it will show the original database name anyway and it will be created for you automatically.
0
 
LVL 1

Expert Comment

by:BradySQL
ID: 39668271
I'm a T-SQL nut so here is what I would do.

RESTORE DATABASE [DatabaseName] FROM  DISK = N'E:\DatabaseName.bak' WITH  FILE = 1,  MOVE N'DatabaseName' TO N'E:\SQLData\DatabaseName.mdf',  MOVE N'DatabaseName_log' TO N'F:\SQLData\DatabaseName.LDF',  NOUNLOAD,  STATS = 1

If you are not sure of the filenames to move them you can run

RESTORE FILELISTONLY FROM  DISK = N'E:\DatabaseName.bak'

This will give you any info that you need to use with your MOVE statement.
0
 

Author Closing Comment

by:bobox00
ID: 39699084
Thanks
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

How to leverage one TLS certificate to encrypt Microsoft SQL traffic and Remote Desktop Services, versus creating multiple tickets for the same server.
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

751 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