Installing AdventureWorks Sample Database
Now the SQL Server and the management studio are ready for using. For training purpose, we need a database with some sample data. It will be very helpful to have a sample database while learning SQL Server. For this purpose, Microsoft has introduced the AdventureWorks Sample Database. Currently, AdventureWorks sample database is available in CodePlex as open source.
Downloading & Extracting AdventureWorks Sample Database
- You can download the sample databases for SQL Server 2014 from CodePlex. There you can see all the different types of sample databases available for download.
- From the list, download the Adventure Works 2014 Full Database Backup.zip below the Recommended Download Section. This is the sample database useful for learning SQL Server basics.
- Once downloaded, unzip the file to extract the sample database backup file named AdventureWorks2014.bak.
- Place the backup file (AdventureWorks2014.bak) under the default SQL Server 2014 backup folder.
- On 64 bit operating system, the default backup folder will be like C:\Program Files\Microsoft SQL Server\MSSQL12.MSSQLSERVER\MSSQL\Backup\.
- On 32 bit OS, use C:\Program Files (x86)\Microsoft SQL Server\…..
- Now, follow one of the below methods to restore this backup file to the SQL Server.
Installing Or Restoring The AdventureWorks Sample Database
A. Restore Sample Database Using SQL Scripts
- Login to the SQL Server Management Studio (SSMS).
- Open a new SQL Query Editor window
- Copy the below code and paste it into the query editor window123456789
USE master
RESTORE
DATABASE
AdventureWorks2014
FROM
disk =
'C:\Program Files\Microsoft SQL Server\MSSQL12.MSSQLSERVER\MSSQL\Backup\AdventureWorks2014.bak'
WITH
MOVE
'AdventureWorks2014_data'
TO
'C:\Program Files\Microsoft SQL Server\MSSQL12.MSSQLSERVER\MSSQL\DATA\AdventureWorks2014.mdf'
,
MOVE
'AdventureWorks2014_Log'
TO
'C:\Program Files\Microsoft SQL Server\MSSQL12.MSSQLSERVER\MSSQL\DATA\AdventureWorks2014.ldf'
,
REPLACE
- Click the Execute icon in the toolbar. You will see the status message as in the below picture once the database is successfully restored.
- You can see the restored sample database in the Object Explorer under Databases folder.
B. Restore Sample Database Using SSMS GUI
- Login to the SQL Server Management Studio (SSMS).
- In the Object Explorer, right-click the Database folder and select Restore Database...
- In the Restore Database screen, choose Devices and click the ellipsis button to launch the backup device selection screen. In the device selection window, press Add button to launch the file dialog. The file dialog will open the default SQL Server backup location. As we have already placed the backup file in that location, just select the backup file in the file dialog and press OK. Again press OK in the device selection window.
- Now the restore database window is filled with the details of the database to be restored from the backup.
- Press the OK button in restore database window. The sample database backup is restored as a new database AdventureWorks2014. You can see the restored sample database in the Object Explorerunder Databases folder.
In my future article on SQL Server Basics series, I’ll be using this sample database for training.