---
title: "What is the best way to Restore Database SQL Server 2012"  
description: "What is the best way to Restore Database SQL Server 2012"  
author: "Anonymous User"  
published: 2015-09-10  
updated: 2015-09-10  
canonical: https://www.mindstick.com/forum/33455/what-is-the-best-way-to-restore-database-sql-server-2012  
category: "mssql server"  
tags: ["database", "mssql server"]  
reading_time: 3 minutes  

---

# What is the best way to Restore Database SQL Server 2012

We have a [database file](https://www.mindstick.com/forum/159377/how-to-add-edit-retrieve-data-using-local-database-file-in-microsoft-visual-studio-2012) that is called main-db.bak.\
\
This is the database file that we have cloned as it contains all the main things we need in the [process](https://yourviews.mindstick.com/story/1525/7-important-factors-that-may-affect-the-learning-process) of constructing new websites for our clients. Is it possible to do the following:\
Have a copy of the database on the same [SQL Server](https://www.mindstick.com/articles/12999/what-is-table-valued-function-in-sql-server) [Instance](https://www.mindstick.com/forum/155658/testing-connection-to-cloud-sql-instance-with-a-mysql-client-from-vm-instance)Create a new empty database[Restore](https://yourviews.mindstick.com/story/1480/ways-to-restore-ecosystems-and-heal-the-planet) the database from main-db.bak file and not overrite anything else that may be using the same data MDF and LDF files?Or would it be easier to reproduce this database from a live running database copy so that it is not needed to restore if from backup?\
Is it mandatory to rename the [LDF and MDF](https://www.mindstick.com/forum/34653/what-are-the-ldf-and-mdf-files-in-sql-server) files when the database is restored, can I script to [automate](https://www.mindstick.com/blog/12040/how-to-automate-your-business) the [majority](https://yourviews.mindstick.com/view/81389/time-for-putin-s-popularity-led-by-majority) of the work?

## Replies

### Reply by Anonymous User

Lets take your questions one by one :\
Is it possible to do the following:Have a copy of the [database](https://www.mindstick.com/articles/12226/use-of-database-in-sencha-extjs-and-insert-record-from-user-form-using-ajax) on the same SQL [Server](https://www.mindstick.com/articles/43769/what-is-serverless-architecture-is-it-worth-switching-over) Instance Yes it is possible. You just have to restore the database main-db.bak with move.e.g. Provided you dont have secondary data files, below will work\
-- find logical names\
restore filelistonly from disk = 'path\main-db.bak'gorestore database main_db_copyfrom disk = 'path\main-db.bak'with recovery, stats = 10,-- below logical data and log file names will be found from the filelistonly mentioned above.move 'logicalDataFileName' to 'PhysicalPath\main-db_data.mdf',move 'logicalLogFileName' to 'PhysicalPath\main-db_log.ldf'Create a new empty databaseNo need to first create an empty database, as the restore with move will create it.\
Restore the database from main-db.bak file and not overrite anything else that may be using the same data MDF and LDF files?Same as above. As restore with move will not over write unless you use restore with REPLACE explicitly to overwrite.\
Or would it be easier to reproduce this database from a live running database copy so that it is not needed to restore if from backup?Cannot understand what you mean by this ! If you want to create a new database or copy of the current database , you have to take a backup and then use restore database to restore it.\
Is it mandatory to rename the LDF and MDF files when the database is restored, can I script to automate the majority of the work?If you want to overwrite the existing one, then no. If not and you want to create a copy of existing one, then Yes - you have to rename the mdf and ldf files.


---

Original Source: https://www.mindstick.com/forum/33455/what-is-the-best-way-to-restore-database-sql-server-2012

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
