AdventureWorks is a sample database for SQL Server and Azure SQL. Adventure Works Cycles is a fictitious company that sells directly to retailers, who then sell products to consumers. Throughout this website exercises we will be using the workflows that are addressed in the AdventureWorks Lightweight (LT) sample database as the bases for our tutorials.
The downloaded .bak file will be used to restore the AdventureWorks sample database to your SQL Server instance. The sample database can be restored using any of the three ways listed below:
The RESTORE (Transact-SQL) command.
The graphical interface (GUI) in SQL Server Management Studio (SSMS).
Azure Data Studio.
1 Download the appropriate AdventureWorks.bak from the official website. For the tutorials on this website, we will be using the AdventureWorks Lightweight (LT) download version. This data download is a lightweight and pared down version of the OLTP sample. This simplified version makes it easier to focus on learning Transact-SQL syntax.
2 Move the .bak file to your SQL Server backup location. This will vary 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 > Restore Database... to launch the Restore Database wizard.
5 Select Device and then select the ellipses (...) 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're not able to see it in the wizard, this typically indicates a permissions issue - 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 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.
The AdventureWorks sample database can also be restored using Transact-SQL (T-SQL). Below is a sample script to restore AdventureWorks2022. Note: the database name and installation file path may vary depending on your environment. Modify values as appropriate to your environment and then run the following Transact-SQL (T-SQL) command:
///////////////////////Copy Code //////////////////To restore AdventureWorks2022 on Linux, change the Windows filesystem path to Linux, and then run the following Transact-SQL (T-SQL) command:
To restore AdventureWorks sample database in Azure Data Studio, follow these steps:
1 Download the appropriate .bak file from one of links provided in the download backup files section.
2 Move the .bak file to your SQL Server backup location. This 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 2019 (15.x) is:
C:\Program Files\Microsoft SQL Server\MSSQL15.MSSQLSERVER\MSSQL\Backup.
3 Open Azure Data Studio and connect to your SQL Server instance.
4 Right-click on your server and select Manage.
5 Select Restore //Select restore from the top menu to restore your database.
6 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.
This auto-populates the rest of the fields such as Database, Target database and Restore to.
Once you have chosen a backup file path, the rest of the fields auto-populate.
7 Select Restore to restore your database.