
Data is increasing at an exponential rate, coming from different sources and creating new opportunities to unleash its potential. There is more need for interaction with this data than ever. SQL — Structured Query Language, pronounced as “S-Q-L” or “Sequel,” is the way to communicate with this humongous data on the servers. It is a language to query databases and a language to talk to databases.
This article is for anyone who wishes to learn SQL but does not know where to start and how to start practicing. You will come across abundant material, tutorials, and courses on SQL online. However, SQL is a skill that is developed only hands-on and not just by reading.
So, if you are a student, a newbie, or anyone who wishes to learn and practice queries in a real-world database environment, then keep reading.
Practice makes SQL perfect!
Microsoft SQL Server is a relational database management system developed by Microsoft. As a database server, the main function is to store and retrieve data as per the queries. MS SQL Server is widely used at corporate and educational levels.
This blog will guide you in setting up Microsoft SQL Server on your computers and running queries on a sample database. The steps to connect the sample database to your server have also been covered in this article.
Let’s get started!
I am using Microsoft SQL Express 2022 and MS SQL Management Studio 20.2. I downloaded these applications from the URLs mentioned below. If these direct URLs do not work, google MS SQL Management Studio and SQL Express and download from the Microsoft links.
2. Once these applications are downloaded and installed, open SQL Management Studio from the start menu, and you will see the following pop-up.
Enter “*. \\sqlexpress*” as the Server name and connect. If your connection is successful, then you can go ahead with Step 3.
Let us add the famous “Northwind” database to our SQL Server. This contains sales data of a hypothetical company called “Northwind Traders”. It is a sample database created by Microsoft for tutorial purposes, which saves us the effort of creating data tables and generating data for our server.
Here is the URL - https://github.com/microsoft/sql-server-samples/blob/master/samples/databases/northwind-pubs/instnwnd.sql
For the purpose of this blog, I have focused on the Northwind database, which is “instnwnd.sql” (highlighted).
Click on the file, and then click Download or Copy. The script will open in the browser. Copy the entire script.
Click on the “New Query” option from the top ribbon, and it will open a window where you can paste the copied script. Select the entire script, and hit the execute button highlighted in the screenshot below.
Once this query gets executed completely, hit refresh by either clicking the “F5” key or clicking on the option shown below.
After refreshing, you should be able to view “Northwind” when you expand the Databases option.
To ensure that everything’s fine let us run a simple query on the Customers table. Before this, make sure that you are connected to the Northwind database, as we are going to run queries on Northwind. Select “Northwind” from the drop-down menu highlighted below.
You can run queries on any table under the “Tables” section. I have chosen the most basic “Select” query to see if the database is working.
SELECT TOP 5 * FROM Customers;
This query retrieves 5 Customers from the Northwind database. If you can view these results, you are all set to explore SQL! The server has been implemented properly, and it functions well.
Indeed, SQL is not difficult, and it does not have a lot of concepts like other programming languages. However, it does require the ability to think about the problem at hand and build logic accordingly. All of this only comes with a lot of hands-on practice.
Happy Querying!