| title | Install and configure AdventureWorks sample database |
|---|---|
| description | Follow these instructions to download and install AdventureWorks sample databases with SQL Server Management Studio or in Azure SQL Database. |
| ms.prod | sql |
| ms.prod_service | sql |
| ms.technology | samples |
| ms.date | 06/19/2018 |
| ms.reviewer | |
| ms.topic | conceptual |
| author | MashaMSFT |
| ms.author | mathoma |
| ms.custom | seo-lt-2019 |
[!INCLUDEappliesto-ss-asdb-asdw-pdw-md]
AdventureWorks download links and installation instructions.
- SQL Server or Azure SQL Database. For the Full version of the sample, use SQL Server Evaluation/Developer/Enterprise Edition.
- SQL Server Management Studio. For the best results use the June 2016 release or later.
Direct links to the OLTP versions of AdventureWorks can be found below:
- AdventureWorks2017.bak
- AdventureWorks2016.bak
- AdventureWorks2014.bak
- AdventureWorks2012.bak
- AdventureWorks2008R2.bak
Direct links to the Data Warehouse versions of AdventureWorks can be found below:
- AdventureWorksDW2017.bak
- AdventureWorksDW2016.bak
- AdventureWorksDW2014.bak
- AdventureWorksDW2012.bak
- AdventureWorksDW2008R2.bak
The below scripts can be used to create the entire AdventureWorks database, irrespective of version.
- All AdventureWorks files for SQL 2014 - 2016
- All AdventureWorks files for SQL 2012
- All AdventureWorks files for SQL 2008 and 2008R2
Follow the below steps to restore a backup of your database using SQL Server Management Studio.
- Open SQL Server Management Studio and connect to the target SQL Server instance.
- Right-click on the Databases node, and select Restore Database.
- Select Device and click the ellipses (...)
- In the dialog Select backup devices, click Add, navigate to the database backup in the filesystem of the server, and select the backup. Click OK.
- If needed, change the target location for the data and log files, in the Files pane. Note that it is best practice to place data and log files on different drives.
- Click OK. This will initiate the database restore. After it completes, you will have the AdventureWorks database installed on your SQL Server instance.
For more information on restoring a SQL Server database, see Restore a database backup using SSMS.
Follow the below steps to attach the datafile for your database using SQL Server Management Studio.
- Open SQL Server Management Studio and connect to the target SQL Server instance.
- Right-click on the Databases node, and select Attach.
- Select Add and navigate to the .MDF file you want to attach.
- Select the file and click OK.
- The database you selected should be displayed in the bottom window. If the file is listed as "not found", select the ellipses (...) next to the file name and update the path to the correct path.
- If you only have the data file (.mdf), and not the log file (.ldf), then highlight the .ldf in the bottom window and select Remove. This will create a new log file.
- Select OK to attach the file. After the file is attached, you will have the AdventureWorks database installed on your SQL Server instance.
For more information on attaching database files, see Attach a database.
If you do not yet have a SQL Server in Azure, navigate to the Azure portal and create a new SQL Database. In the process of creating a database, you will create a server. Make note of the server. See this tutorial to create a database in minutes.
- Connect to your Azure portal.
- Select Create a resource in the top left of the navigation pane.
- Select Databases and then select SQL Database.
- Fill in the requested information.
- In the Select Source field, select Sample (AdventureWorksLT) to restore a backup of the latest AdventureWorksLT backup.
- Select Create to create your new SQL Database, which is the restored copy of the AdventureWorksLT database.
Tutorials for SQL Server Management Studio
Tutorials for SQL Server database engine