Tuesday, April 28, 2015

SQL 2014 - Restore a SQL Database




Launch the SQL Server Management Studio from the start menu.


Login to the SQL Server as the SA User.
Expand the server name and right click the databases folder.

Choose Restore Database from the list.

Click the Device: Radio box and then click the three dots (...) to browse for the database file.
Select the Add option to browse to the files.
Select the BAK file from the window. If this is not named BAK choose All files from the bottom right drop down window. Not all SQL database files must end in BAK, although that is the preferred file extension.
Click OK to add the file.
The file path and Database name under Source > Device  the information will auto fill based on the SQL backup profile.

Enter in  a new Database Name under the Destination section. If not already clicked go ahead and check  the Restore Checkbox and select OK.












You should now see the database in the Database folder. 





Now that the restore is complete we should update the SQL Server with some information about our new database.


Click on the Database name on the left tab and at the top of the page click the "New Query" button. This will open a new page on the right of the screen.




Enter in new windows "SP_UPDATESTATS" this is not case sensitive and does not need the quotes. Once entered press the Execute button to run the script. 
The results will display down below.
Next enter the command
DBCC Updateusage(DBName)
and press the execute button. Replace DBName with your Database name found on the left side. 

Again the results are displayed. 
Finally we will run the Integrity and Optimization checks built into SQL. 

Type DBCC CheckDB and press execute. 


Your Database should return no Integrity and Optimization errors. 


No comments:

Post a Comment