From the course: Querying Microsoft SQL Server 2022

Download the sample database

- [Instructor] Querying a database is all about pulling useful information out of your tables. In order to learn about queries and SQL Server, we need to have a database with some interesting data that we can review. For this course, I'm going to use the sample database for a fictional company called AdventureWorks. You can find a download link to the database from the Microsoft GitHub page. I'm going to scroll down on this page here a little bit until I get to the downloadable backup files. Now, there's different versions of AdventureWorks for different versions of SQL Server, but the data that all of these databases contain is exactly the same. So, it really doesn't matter which of these you choose. I'm just going to choose the most recent version for AdventureWorks2019 and this will download the bak or the database backup file. Once it's done downloading, we need to move it into position on our file system. I'll go ahead and minimize my web browser, and we'll go into the Downloads folder where I'll find the file that it just downloaded and I'm going to cut it to my clipboard. Then we'll go into the C: Drive, program files, Microsoft SQL Server, the folder for the server instance that we're working with. Mine is called MSSQL.16.MSSQLSERVER. We'll go in there inside of the MSSSQL folder and finally we'll go into the backup folder. Now, the first time you try and do this, you may get this message that tells you that you don't currently have permission to access the folder. You should be able to press Continue though, to be let in. Otherwise, you might have to right click on that folder and go to the folder's properties and then adjust these security settings in order to get into this backup folder. Once you get in though, just right click and say Paste to paste in the backup file. All right, now we can go into SSMS and restore this backup onto our server. In the object explorer on the far left hand side, I'll right click the Databases folder underneath our server connection. Then I'll choose the option to Restore a Database. Next, we'll choose the source is the Device or the hard drive that we're pulling our information from. So, I'll choose Device and then click the ellipsis button on the right. Here, we'll choose to use a Backup media type of file and press Add. That should bring up the backup folder that we were just in and there is the AdventureWorks2019 backup file. I'll select it and say, OK. Press OK on this screen. And OK one more time to restore the database. Once it's restored, I'll press OK and that dismisses the workflow. And then over here in the Object Explorer you'll see the new AdventureWorks database. If you're not seeing it, just right click and choose Refresh, and you should see it pop up there. And now we can expand it and expand the tables to see all of the different data tables that this database contains. So, now we have lots of interesting information that we can use to explore how to leverage queries in SQL Server 2022.

Contents