Installing a Sample Database

AdventureWorks2022

Posted by: Aubrey W Love on November 27, 2023
Introduction

A problem that you may encounter when trying to install (restore) the AdventureWorks2022 sample database on a SQL Server 2019 instance, is that you recieve an error message like the one in Figure.1.

Figure.1

To overcome this issue, you are going to need to install SQL Server 2022. According to Microsoft, it's the only solution. If you haven't done so already, refer back to the article "Install SQL Server 2022 Developer Edition".

Finding the AdventureWorks2022 sample database

You can get a free copy of the AdventureWorks2022 sample database by clicking on this link.
AdventureWorks2022
You should see the Microsoft sample database download page. Scroll down until you see the section like in Figure.2 and select the link for "AdventureWorks2022.bak".

Figure.2

Once the download begins, select a folder to save the file to. At this point, it doesn't matter where, just as long as you remember where you saved it.
  • example Do not save this file to your "Downloads" folder. It's best to create a "temp" folder on your drive C: or a second drive in your computer. For this example, I'm saving it to a folder on drive C: called "temp".

Installing (Restoring) the AdventureWorks2022 sample database

This process is pretty easy, but if you know me, you know I'm going to complicate it. (Humor) Open SQL Server Management Studio (SSMS) and connect to your SQL Server 2022 instance.
In your Object Explorer, right-click on "Databases" and select "Restore Database..." from the drop-down menu.

Figure.3

In the dialouge box that opens, select the "Device" radio button (#1) and click on the elipses (#2).

Figure.4

In the next dialouge box, click the "Add" button.

Figure.5

Navigate to the folder where you saved the AdventureWorks2022.bak file.

Figure.6
Click "OK" and click "OK" again on the next dialouge box. This should take you back to "Restore Database" screen as shown below in Figure.7.
Figure.7
Remember back in the SQL Server 2022 instance install article, steps 17 and 21, where I said there was an easier way to change where your data files could be saved in a different folder. Well, here is where you can do that.
  • example As a general rule, you should not save your data files on drive C:. Always save them to another hard drive in your computer. It's also a preferred practice to NOT keep the “mdf” and “ldf” files on the same drive.

If you refer back to Figure.7, you will notice that "pointed out" the "Files" option in the left pane. Click on that and let's change where my data files will be stored.

In the next dialouge box, shown in Figure.8, click on the elipses where the red arrow is in the image.

Figure.8

In the next dialouge box, navigate to the folder where you want to keep your data files. In my example, I am relocating them to a seperate folder on drive E: As you can see in the first red box in Figure.9. E:\SQL_All\SQL_2022_Data
In the second red box area, type the name and extension for sample database file. In my sample, I just used the name "AdventureWorks2022.mdf".

Figure.9

Repeat this process for the log files by clicking on the elipses next to the second line as shown in Figure.10 below.

Figure.10

Remember, the log file name should include the word "log" and the extension should be "ldf". AdventureWorks2022_log.ldf
When you have the folder and file names set, click "OK". If all went well, you should see the following message.

Figure.11

Okay, I know you're ready to jump right in and start querying data, but there are some additional things you really need to know before you start querying and modifying data.
The next rational step is to learn RDBMS and Set Theory. Those are explained in the next article found here.

On a side note, if you really want to start playing, go ahead. If you mess up the data, tables, views, etc. you can always drop your sample database and restore it again at any time. Remember, it's just a sample database.



Want to start your own blog or maybe
dip your toes into the world of writting?

Click on the following links.

Qries
HubSpot Website Design Services