You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
title: "Install and configure AdventureWorks sample database"
3
-
description: Follow these instructions to download and install AdventureWorks sample databases with SQL Server Management Studio or in Azure SQL Database.
2
+
title: "AdventureWorks sample databases"
3
+
description: Follow these instructions to download and install AdventureWorks sample databases to SQL Server or Azure SQL Database.
AdventureWorks download links and installation instructions.
17
+
This article provides direct links to download AdventureWorks sample databases, as well as instructions for restoring them to SQL Server and Azure SQL Database.
18
+
19
+
For more information about samples, see the [Samples GitHub repository](https://github.com/microsoft/sql-server-samples/tree/master/samples/databases).
18
20
19
21
## Prerequisites
20
22
21
-
-[SQL Server](https://www.microsoft.com/evalcenter/evaluate-sql-server-2016) or [Azure SQL Database](https://azure.microsoft.com/services/sql-database/). For the Full version of the sample, use SQL Server Evaluation/Developer/Enterprise Edition.
22
-
-[SQL Server Management Studio](../ssms/download-sql-server-management-studio-ssms.md). For the best results use the June 2016 release or later.
23
-
24
-
## OLTP downloads
23
+
-[SQL Server](https://www.microsoft.com/evalcenter/evaluate-sql-server-2019) or [Azure SQL Database](https://azure.microsoft.com/services/sql-database/).
24
+
-[SQL Server Management Studio](../ssms/download-sql-server-management-studio-ssms.md) or [Azure Data Studio](../azure-data-studio/download-azure-data-studio.md). or later.
25
25
26
-
Direct links to the OLTP versions of AdventureWorks can be found below:
You can use the `.bak` file to restore your sample database to your SQL Server instance. You can do so using the graphical interface (GUI) in [SQL Server Management Studio](../ssms/download-sql-server-management-studio-ssms.md) or [Azure Data Studio](../azure-data-studio/download-azure-data-studio.md), or using the [RESTORE (Transact-SQL)](../t-sql/statements/restore-statements-transact-sql.md) command.
55
+
56
+
### GUI
57
+
58
+
You can restore your database using the GUI in SQL Server Management Studio or Azure Data Studio.
59
+
60
+
# [SQL Server Management Studio (SSMS)](#tab/ssms)
61
+
62
+
If you're not familiar using SQL Server Management Studio (SSMS), you can see [connect & query](../ssms/tutorials/connect-query-sql-server.md) to get started.
63
+
64
+
To restore your database in SQL Server Management Studio, follow these steps:
65
+
66
+
1. Download the appropriate `.bak` file from one of links provided in the [.bak download files](#download-bak-files) section.
67
+
1. Move the `.bak` file to your SQL Server backup location. This varies depending on your installation location, instance name and version of SQL Server. The default location for a default instance of SQL Server 2019 is `C:\Program Files\Microsoft SQL Server\MSSQL15.MSSQLSERVER\MSSQL\Backup`.
68
+
1. Open SQL Server Management Studio (SSMS) and connect to your SQL Server.
69
+
1. Right-click **Databases** in **Object Explorer** > **Restore Database...** to launch the **Restore Database** wizard.
52
70
53
-
-[All AdventureWorks files for SQL 2014 - 2016](https://github.com/Microsoft/sql-server-samples/releases/tag/adventureworks)
54
-
-[All AdventureWorks files for SQL 2012](https://github.com/Microsoft/sql-server-samples/releases/tag/adventureworks2012)
55
-
-[All AdventureWorks files for SQL 2008 and 2008R2](https://github.com/Microsoft/sql-server-samples/releases/tag/adventureworks2008r2)
71
+
:::image type="content" source="media/adventureworks-install-configure/restore-db-ssms.png" alt-text="Choose to restore your database by right-clicking databases in Object Explorer and then selecting Restore Database":::
56
72
57
-
## Install to SQL Server
58
73
59
-
### Restore backup
60
-
Follow the below steps to restore a backup of your database using SQL Server Management Studio.
74
+
1. Select **Device** and then select the ellipses **(...)** to choose a device.
75
+
1. Select **Add** and then choose the `.bak` file you recently moved to this 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 does not have permission to this file in this folder.
76
+
1. Select **OK** to confirm your database backup selection and close the **Select backup devices** window.
77
+
1. 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.
78
+
1. Select **OK** to restore your database.
61
79
62
-
1. Open SQL Server Management Studio and connect to the target SQL Server instance.
63
-
2. Right-click on the **Databases** node, and select **Restore Database**.
64
-
3. Select **Device** and click the ellipses (**...**)
65
-
4. 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**.
66
-
5. 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.
67
-
6. Click **OK**. This will initiate the database restore. After it completes, you will have the AdventureWorks database installed on your SQL Server instance.
80
+
:::image type="content" source="media/adventureworks-install-configure/restore-db-wizard-ssms.png" alt-text="Choose to restore your database by right-clicking databases in Object Explorer and then selecting Restore Database":::
68
81
69
82
For more information on restoring a SQL Server database, see [Restore a database backup using SSMS](../relational-databases/backup-restore/restore-a-database-backup-using-ssms.md).
70
83
84
+
# [Azure Data Studio](#tab/data-studio)
85
+
86
+
If you're not familiar using Azure Data Studio, you can see [connect & query](../azure-data-studio/quickstart-sql-server.md) to get started
87
+
88
+
To restore your database in Azure Data Studio (SSMS), follow these steps:
89
+
90
+
1. Download the appropriate `.bak` file from one of links provided in the [.bak download files](#download-bak-files) section.
91
+
1. Move the `.bak` file to your SQL Server backup location. This varies depending on your installation location, instance name and version of SQL Server. The default location for a default instance of SQL Server 2019 is `C:\Program Files\Microsoft SQL Server\MSSQL15.MSSQLSERVER\MSSQL\Backup`.
92
+
1. Open Azure Data Studio Studio (SSMS) and connect to your SQL Server.
93
+
1. Right-click **Databases** in **?????** > **Restore** to launch the **?????** wizard.
94
+
95
+
:::image type="content" source="media/adventureworks-install-configure/restore-db-ssms.png" alt-text="Choose to restore your database by right-clicking databases in Object Explorer and then selecting Restore Database":::
96
+
97
+
1. ???????????
98
+
1. ???????????
99
+
1. ??????????????
100
+
1. 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.
101
+
1. Select **OK** to restore your database.
102
+
103
+
:::image type="content" source="media/adventureworks-install-configure/restore-db-wizard-ssms.png" alt-text="Choose to restore your database by right-clicking databases in Object Explorer and then selecting Restore Database":::
104
+
105
+
---
106
+
107
+
### Transact-SQL (T-SQL)
108
+
109
+
You can restore your sample database using Transact-SQL (T-SQL) as well. An example to restore AdventureWorks2019 is provided below, but the database name and installation file path may vary depending on your environment.
110
+
111
+
To restore AdventureWorks2019, modify values as appropriate to your environment and then run the following Transact-SQL (T-SQL) command:
71
112
72
-
### Attach a datafile
73
-
Follow the below steps to attach the datafile for your database using SQL Server Management Studio.
113
+
```sql
114
+
USE [master]
115
+
RESTORE DATABASE [AdventureWorks2019]
116
+
FROM DISK = N'C:\Program Files\Microsoft SQL Server\MSSQL15.MSSQLSERVER\MSSQL\Backup\AdventureWorks2019.bak'
117
+
WITH FILE =1, NOUNLOAD, STATS =5
118
+
GO
74
119
75
-
1. Open SQL Server Management Studio and connect to the target SQL Server instance.
76
-
2. Right-click on the **Databases** node, and select **Attach**.
77
-
3. Select **Add** and navigate to the .MDF file you want to attach.
78
-
1. Select the file and click **OK**.
79
-
1. 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.
80
-
1. 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.
81
-
1. Select **OK** to attach the file. After the file is attached, you will have the AdventureWorks database installed on your SQL Server instance.
120
+
```
82
121
83
-
For more information on attaching database files, see [Attach a database](../relational-databases/databases/attach-a-database.md).
122
+
## Deploy to Azure SQL Database
84
123
85
-
## Install to Azure SQL Database
124
+
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 SQL Server directly to Azure using SQL Server Management Studio (SSMS).
86
125
126
+
To get sample data for Azure SQL Managed Instance instead, see [restore World Wide Importers to SQL Managed Instance](/azure/azure-sql/managed-instance/restore-sample-database-quickstart).
87
127
88
-
If you do not yet have a SQL Server in Azure, navigate to the [Azure portal](https://portal.azure.com/) 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](https://azure.microsoft.com/documentation/articles/sql-database-get-started/) to create a database in minutes.
128
+
### Deploy new sample database
129
+
130
+
When you create a new database in Azure SQL Database, you have the option to create a blank database, or a sample database.
131
+
132
+
Follow these steps to use a sample database to create a new database:
89
133
90
134
1. Connect to your Azure portal.
91
135
1. Select **Create a resource** in the top left of the navigation pane.
92
136
1. Select **Databases** and then select **SQL Database**.
93
-
1. Fill in the requested information.
94
-
1. In the **Select Source** field, select **Sample (AdventureWorksLT)** to restore a backup of the latest AdventureWorksLT backup.
137
+
1. Fill in the requested information to create your database.
138
+
1. On the **Additional settings** tab, choose **Sample** as the existing data under **Data source**:
139
+
140
+
:::image type="content" source="media/adventureworks-install-configure/deploy-sample-to-azure.png" alt-text="Choose sample as the data source on the Additional settings tab in the Azure portal when creating your Azure SQL Database":::
141
+
95
142
1. Select **Create** to create your new SQL Database, which is the restored copy of the AdventureWorksLT database.
96
143
97
144
98
-
## See also
145
+
### Deploy database from SQL Server
146
+
147
+
SQL Server Management Studio provides the ability to deploy a database directly to Azure SQL Database. This method does not currently provide data validation so is intended for development and testing and should not be used for production.
148
+
149
+
To deploy a sample database from SQL Server to Azure SQL Database, follow these steps:
150
+
151
+
1. Connect to your SQL Server in SQL Server Management Studio.
152
+
1. If you haven't already done so, [restore the sample database to SQL Server](#restore-to-sql-server).
153
+
1. Right-click your restored database > **Tasks** > **Deploy Database to Microsoft Azure SQL Database...**.
154
+
155
+
:::image type="content" source="media/adventureworks-install-configure/deploy-db-to-azure.png" alt-text="Choose to deploy your database to Microsoft Azure SQL Database from right-clicking your database and selecting Tasks":::
156
+
157
+
1. Follow the wizard to connect to your Azure SQL Database and deploy your database.
158
+
159
+
160
+
## Creation scripts
161
+
162
+
Instead of restoring a database, alternatively, you can use scripts to create the AdventureWorks databases regardless of version.
163
+
164
+
The below scripts can be used to create the entire AdventureWorks database:
0 commit comments