title | description | author | ms.author | ms.reviewer | ms.date | ms.service | ms.subservice | ms.topic |
---|---|---|---|---|---|---|---|---|
AdventureWorks sample databases |
Follow these instructions to download and install AdventureWorks sample databases to SQL Server using Transact-SQL (T-SQL), SQL Server Management Studio (SSMS), or Azure Data Studio. |
MashaMSFT |
mathoma |
randolphwest |
05/09/2024 |
sql |
samples |
conceptual |
[!INCLUDE SQL Server Azure SQL Database Synapse Analytics PDW]
This article provides direct links to download 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.
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.
Additional files can be found directly on GitHub:
You can use the .bak
file to restore your sample database to your [!INCLUDE ssnoversion-md] instance. You can do so using the RESTORE Statements command, or using the graphical interface (GUI) in SQL Server Management Studio (SSMS) or Azure Data Studio.
If you're not familiar using SQL Server Management Studio (SSMS), you can see connect & query to get started.
To restore your database in SSMS, follow these steps:
-
Download the appropriate
.bak
file from one of links provided in the download backup files section. -
Move the
.bak
file to your [!INCLUDE ssnoversion-md] backup location. This location varies depending on your installation location, instance name, and version of [!INCLUDE ssnoversion-md]. For example, the default location for a default instance of [!INCLUDE sssql22-md] is:C:\Program Files\Microsoft SQL Server\MSSQL16.MSSQLSERVER\MSSQL\Backup
-
Open SSMS and connect to your [!INCLUDE ssnoversion-md] instance.
-
Right-click Databases in Object Explorer > Restore Database... to launch the Restore Database wizard.
:::image type="content" source="media/adventureworks-install-configure/restore-db-ssms.png" alt-text="Screenshot showing how to choose to restore your database by right-clicking databases in Object Explorer and then selecting Restore Database.":::
-
Select Device and then select the ellipses (...) to choose a device.
-
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're not able to see it in the wizard, [!INCLUDE ssnoversion-md] or the user signed into [!INCLUDE ssnoversion-md] doesn't have permission to this file in this folder. -
Select OK to confirm your database backup selection and close the Select backup devices window.
-
Check the Files tab to confirm the Restore as location and file names match your intended location and file names in the Restore Database wizard.
-
Select OK to restore your database.
:::image type="content" source="media/adventureworks-install-configure/restore-db-wizard-ssms.png" alt-text="Screenshot showing the Restore Database window with the backup set to restore highlighted and the OK option highlighted." lightbox="media/adventureworks-install-configure/restore-db-wizard-ssms.png":::
For more information on restoring a [!INCLUDE ssnoversion-md] database, see Restore a database backup using SSMS.
You can restore your sample database using Transact-SQL (T-SQL). An example to restore [!INCLUDE sssampledbobject-md] is provided in the following example, but the database name and installation file path can vary depending on your environment.
To restore [!INCLUDE sssampledbobject-md] on Windows, modify values as appropriate to your environment and then run the following Transact-SQL (T-SQL) command:
USE [master];
GO
RESTORE DATABASE [AdventureWorks2022]
FROM DISK = N'C:\Program Files\Microsoft SQL Server\MSSQL16.MSSQLSERVER\MSSQL\Backup\AdventureWorks2022.bak'
WITH
FILE = 1,
NOUNLOAD,
STATS = 5;
GO
To restore [!INCLUDE sssampledbobject-md] on Linux, change the Windows filesystem path to Linux, and then run the following Transact-SQL (T-SQL) command:
USE [master];
GO
RESTORE DATABASE [AdventureWorks2022]
FROM DISK = '/var/opt/mssql/backup/AdventureWorks2022.bak'
WITH
MOVE 'AdventureWorks2022' TO '/var/opt/mssql/data/AdventureWorks2022_Data.mdf',
MOVE 'AdventureWorks2022_log' TO '/var/opt/mssql/data/AdventureWorks2022_log.ldf',
FILE = 1,
NOUNLOAD,
STATS = 5;
GO
If you're not familiar using Azure Data Studio Studio, see connect & query to get started.
To restore your database in Azure Data Studio, follow these steps:
-
Download the appropriate
.bak
file from one of links provided in the download backup files section. -
Move the
.bak
file to your [!INCLUDE ssnoversion-md] backup location. This location varies depending on your installation location, instance name, and version of [!INCLUDE ssnoversion-md]. For example, the default location for a default instance of [!INCLUDE sssql22-md] is:C:\Program Files\Microsoft SQL Server\MSSQL16.MSSQLSERVER\MSSQL\Backup
-
Open Azure Data Studio and connect to your [!INCLUDE ssnoversion-md] instance.
-
Right-click on your server and select Manage.
:::image type="content" source="media/adventureworks-install-configure/ads-manage.png" alt-text="Screenshot showing Azure Data Studio with the Manage option highlighted and called out." lightbox="media/adventureworks-install-configure/ads-manage.png":::
-
Select Restore
:::image type="content" source="media/adventureworks-install-configure/ads-restore-database.png" alt-text="Screenshot of selecting restore from the top menu to restore your database." lightbox="media/adventureworks-install-configure/ads-restore-database.png":::
-
On the General tab, fill in the values listed under Source.
- Under Restore from, select Backup file.
- Under Backup file path, select the location you stored the .bak file.
:::image type="content" source="media/adventureworks-install-configure/ads-source.png" alt-text="Screenshot of selecting your backup file path." lightbox="media/adventureworks-install-configure/ads-source.png":::
This step autopopulates the rest of the fields such as Database, Target database and Restore to.
:::image type="content" source="media/adventureworks-install-configure/ads-destination-restore-plan.png" alt-text="Screenshot of fields autopopulating." lightbox="media/adventureworks-install-configure/ads-destination-restore-plan.png":::
-
Select Restore to restore your database.
:::image type="content" source="media/adventureworks-install-configure/ads-restore.png" alt-text="Screenshot of restoring your database.":::
You have two options to view sample Azure SQL Database data. You can use a sample when you create a new database, or you can deploy a database from [!INCLUDE ssnoversion-md] directly to Azure using SSMS.
To get sample data for Azure SQL Managed Instance instead, see restore World Wide Importers to SQL Managed Instance.
When you create a new database in Azure 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 a sample data to your new database:
-
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 to create your database.
-
On the Additional settings tab, choose Sample as the existing data under Data source:
:::image type="content" source="media/adventureworks-install-configure/deploy-sample-to-azure.png" alt-text="Screenshot of Choose sample as the data source on the Additional settings tab in the Azure portal when creating your Azure SQL Database." lightbox="media/adventureworks-install-configure/deploy-sample-to-azure.png":::
-
Select Create to create your new SQL Database, which is the restored copy of the
AdventureWorksLT
database.
SSMS allows you to deploy a database directly to Azure SQL Database. This method doesn't currently provide data validation so is intended for development and testing and shouldn't be used for production.
To deploy a sample database from [!INCLUDE ssnoversion-md] to Azure SQL Database, follow these steps:
-
Connect to your [!INCLUDE ssnoversion-md] in SSMS.
-
If you haven't already done so, restore the sample database to SQL Server.
-
Right-click your restored database in Object Explorer > Tasks > Deploy Database to Microsoft Azure SQL Database....
:::image type="content" source="media/adventureworks-install-configure/deploy-db-to-azure.png" alt-text="Screenshot of Choose to deploy your database to Microsoft Azure SQL Database from right-clicking your database and selecting Tasks.":::
-
Follow the wizard to connect to Azure SQL Database and deploy your database.
Instead of restoring a database, alternatively, you can use scripts to create the AdventureWorks
databases regardless of version.
The below scripts can be used to create the entire AdventureWorks
database:
Additional information about using the scripts can be found on GitHub.