Restoring A database in SQL Server

Today we discuss a powerful topic, restoring a database into your sql server instance. This can be done for a variety of reasons, if there is a critical error commited that deletes sensitive data and you do not have a differential backup you could have to restore the entire database. That scenario has only happened to me a couple of times in a production enviorment, I take care to approve all database updates and create table backups to avoid this situation.

For this demo we will be pulling a sample database called Adventure Works DW 2012 . The download will prompt when you click the link.

Now go to your SQL server Management Studio interface, right click Databases.

Select Attach Database.

You will be prompted with the Attach Database dialogue box.

Click Add…

Now Navigate to where you extracted the Adventure Works MDF file.

You can remove the LDF from the file selection.

The default location for mdf files are similar to : C:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\DATA\

You can change the location to another drive if you wish.

Verify that the current File Path is the actual path to the MDF file.

Now Click Ok.

Right click on databases and refresh, your new database should be in the database list now!

The process is slightly different from a .bak file which I will cover in another blog post soon.

Ian Fogelman

Ian Fogelman

My name is Ian Fogelman. I like to develop data driven solutions with SQL Server, Python, .NET and predictive analytics.