Solved

How to restore a database

Posted on 2013-11-21
5
197 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
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 26

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

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SQL Help 27 45
VB.NET 2008 - SQL Timeout 9 24
Increment column based of a FK 8 23
SQL Syntax: How to force case sensitive query? 2 30
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 shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
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…
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

809 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