Edit

Share via


AdventureWorks sample databases

Applies to: SQL Server Azure SQL Database Azure SQL Managed Instance Azure Synapse Analytics Analytics Platform System (PDW)

This article provides direct links for downloading AdventureWorks sample databases and instructions for restoring them to SQL Server, Azure SQL Database, and Azure SQL Managed Instance.

For more information about samples, see the Samples GitHub repository.

Prerequisites

Download backup files

Use these links to download the appropriate sample database for your scenario.

  • OLTP data is for most typical online transaction processing workloads.
  • Data Warehouse (DW) data is for data warehousing workloads.
  • Lightweight (LT) data is a lightweight and pared down version of the OLTP sample.

If you're not sure what you need, start with the OLTP version that matches your SQL Server version.

OLTP Data Warehouse Lightweight
AdventureWorks2022.bak AdventureWorksDW2022.bak AdventureWorksLT2022.bak
AdventureWorks2019.bak AdventureWorksDW2019.bak AdventureWorksLT2019.bak
AdventureWorks2017.bak AdventureWorksDW2017.bak AdventureWorksLT2017.bak
AdventureWorks2016.bak AdventureWorksDW2016.bak AdventureWorksLT2016.bak
AdventureWorks2016_EXT.bak AdventureWorksDW2016_EXT.bak N/A
AdventureWorks2014.bak AdventureWorksDW2014.bak AdventureWorksLT2014.bak
AdventureWorks2012.bak AdventureWorksDW2012.bak AdventureWorksLT2012.bak
AdventureWorks2008R2.bak AdventureWorksDW2008R2.bak N/A

You can find additional files on GitHub:

Restore to SQL Server

You can use the .bak file to restore your sample database to your SQL Server instance. You can do so by using the RESTORE statements command or by using the graphical interface (GUI) in SSMS or Azure Data Studio.

If you're not familiar with using SSMS, you can review Connect and query using SSMS to get started.

To restore your database in SSMS, follow these steps:

  1. Download the appropriate .bak file from one of links provided in the Download backup files section of this article.

  2. Move the .bak file to your SQL Server backup location. This location varies depending on your installation location, instance name, and version of SQL Server. For example, the default location for a default instance of SQL Server 2022 (16.x) is:

    C:\Program Files\Microsoft SQL Server\MSSQL16.MSSQLSERVER\MSSQL\Backup
    
  3. Open SSMS and connect to your SQL Server instance.

  4. Right-click Databases in Object Explorer and then select Restore Database... to start the Restore Database wizard.

    Screenshot showing the steps for starting the Restore Database wizard.

  5. Select Device, and then select the ellipsis (...) to choose a device.

  6. Select Add, and then choose the .bak file you recently moved to the backup location. If you moved your file to this location but you don't see it in the wizard, SQL Server or the user signed into SQL Server doesn't have permission to this file in this folder.

  7. Select OK to confirm your database backup selection and close the Select backup devices window.

  8. Check the Files tab to confirm that the Restore as location and file names match your intended location and file names in the Restore Database wizard.

  9. Select OK to restore your database.

    Screenshot showing the Restore Database window. The backup set to restore and the OK option are highlighted.

For more information on restoring a SQL Server database, see Restore a database backup using SSMS.

Deploy to Azure SQL Database

You have two options for viewing sample SQL Database data. You can use a sample when you create a new database, or you can deploy a database from SQL Server directly to Azure by using SSMS.

To get sample data for SQL Managed Instance instead, see Restore World Wide Importers to SQL Managed Instance.

Deploy a new sample database

When you create a new database in SQL Database, you can create a blank database, restore from a backup, or select sample data to populate your new database.

Follow these steps to add sample data to your new database:

  1. Connect to the Azure portal.

  2. Select Create a resource at the top of the left pane.

  3. Select Databases, and then select SQL Database.

  4. Supply the requested information to create your database.

  5. On the Additional settings tab, select Sample under Use existing data:

    Screenshot that shows the Sample option under Use existing data.

  6. Select Create to create your new database, which is the restored copy of the AdventureWorksLT database.

Deploy a database from SQL Server

SSMS allows you to deploy a database directly to SQL Database. This method doesn't currently provide data validation, so it's intended for development and testing and shouldn't be used for production.

To deploy a sample database from SQL Server to SQL Database, follow these steps:

  1. Connect to your SQL Server in SSMS.

  2. If you haven't already done so, restore the sample database to SQL Server.

  3. Right-click your restored database in Object Explorer and then select Tasks > Deploy Database to Microsoft Azure SQL Database.

    Screenshot that shows the menu steps for deploying a database to SQL Database.

  4. Complete the steps in the wizard to connect to SQL Database and deploy your database.

Scripts for creating a database

Instead of restoring a database, you can use scripts to create the AdventureWorks databases, regardless of version.

You can use the following scripts to create the entire AdventureWorks database:

You can find additional information about using the scripts on GitHub.