Jan 07

So you want to learn SQL Server? – Part 2

In Part 1 of this series, we learned how to do a very basic install of the free version of SQL Server (Express Ed.) in order to start learning the basics. In Part 2, we will be downloading a sample database called AdventureWorks that we can attach to our SQL Server instance and begin using right away.

The first thing you need to do is download the sample database here. If that link doesn’t start your download for you, go to http://msftdbprodsamples.codeplex.com/releases/view/125550. You will want the .zip file found in the “Recommended Download” section. The file is named  “Adventure Works 2014 Full Database Backup.zip”. Go ahead and save that file to a known location like downloads so that you can reference it when it is complete.

Once you have that file, navigate to where the file is and right-click on the file to being up the options and select “Extract All…”. This will bring up another window that will allow you to extract or unzip the file:




Either choose a new path or just go ahead and click on Extract. It will open up the folder with the extracted file for you. It will look like this:


In SQL Server, we give backup files the extension .bak. This is a backup file that can be restored using SQL Server Management Studio (SSMS) that we installed earlier or by some other options like scripting. Note the file path and name (or just keep it open to copy and paste).

Now we can go and open SSMS and connect to our local instance of SQL Server. If you are using Windows 8.1 or later, use the shortcut Windows+s and search for “SQL Server Management Studio”. If you are on an older version or prefer to navigate, just go to “All Programs” or “All Apps” find the folder for “Microsoft SQL Server 2014” and expand it. Then go to “SQL Server Management Studio 2014”. Open that up and a window will pop up that looks like below, but you will have to type in “localhost” for the server name.TestInstall1

Now, you can click “Connect” giving you the screen below:


If you click on the + to the left of the Databases folder to expand it out, you will only see another folder for “System Databases” that we will ignore for now. What you are really seeing is that you have no “User” databases to query. To restore our AdventureWorks2014 database, you can right-click on the Databases folder and select the “Restore Database” option will will open up a window:


To restore from a file, we’ll change the Source to “Device” and either use the path of the .bak file that we extracted earlier or just use the ellipsis to navigate to the path and click on the file name:


Once you click OK, it will take a couple seconds to a minute to restore, depending on your CPU and disk speed. Now you will see the AdventureWorks2014 database in the window on the left.


Now, you can expand that out and look at some of the objects contained within a database. They are displayed in folders just like a file structure when you look at them using SQL Server Management Studio. In Part 3, we will write our first SQL query against this database. However, if you can’t wait for me to write Part 3, I suggest checking out SQLServerCentral.com’s Stairway to T-SQL DML. I HIGHLY recommend SQLServerCentral.com for their stairways, forums, and articles. If you don’t already have an account there, go sign up now! If you have any questions or this doesn’t work. Email me at jkarney@sqlknowitall.com or send a tweet to #SQLHelp





Leave a Reply