SQL Server Day 1

An introductory guide to setting up Microsoft SQL Server, understanding SSMS, and running essential SQL queries.

What is SQL Server?

SQL Server is a Database Management System (DBMS) developed by Microsoft. It is used to store and manage data securely.

Many organizations rely on SQL Server every day, including:

Banks Hospitals Colleges Government Offices Shopping Websites IT Companies
[Simple Analogy]: Think of SQL Server as a digital storage room where all important information is safely organized and stored.

What is SSMS?

SSMS (SQL Server Management Studio) is the software that allows us to interact with SQL Server. Using SSMS, we can:

  • Create databases and create tables
  • Insert data and retrieve data
  • Update records and delete records
  • Backup databases and restore databases
Class Pop Quiz #1

1. What is Microsoft SQL Server?

2. Why do we install SSMS (SQL Server Management Studio)?

Installing SQL Server Express & SSMS

Download both official tools free from Microsoft before following the setup steps below:

Microsoft SQL Server Express

Free database engine edition ideal for beginners, students, and local development.

Download SQL Server Express

SQL Server Management Studio (SSMS)

Official Microsoft studio to connect to SQL Server and execute queries.

Download SSMS (Official)
Step 1: Install SQL Server Express
  1. Download SQL Server Express from Microsoft's official website.
  2. Run the installer.
  3. Choose Basic Installation.
  4. Accept the license agreement.
  5. Wait until the installation is completed.
Step 2: Install SQL Server Management Studio (SSMS)
  1. Download SSMS from Microsoft's official website.
  2. Run the installer.
  3. Click Install.
  4. Wait for the installation to complete.
  5. Restart the computer if prompted.
Step 3: Open SSMS
  1. Click the Start Menu.
  2. Search for SQL Server Management Studio.
  3. Open the application.
Step 4: Connect to SQL Server

Use the following settings in the connection window:

Setting Value
Server Type Database Engine
Authentication Windows Authentication
Class Pop Quiz #2

You just opened SSMS for the first time. Which Server Type and Authentication mode should you choose to connect locally?

Answer: Select Database Engine for the Server Type and Windows Authentication for Authentication. Also make sure you chose Basic Installation when installing SQL Server Express.

Understanding the SSMS Interface

Once connected, you will work with these seven parts of the SSMS workspace:

1. Object Explorer

Located on the left side. Think of it as the File Explorer of SQL Server. Expand folders to view:

  • Databases & Tables
  • Views & Stored Procedures
  • Security & Programmability

2. Databases Folder

Inside Object Explorer, expand Databases to see:

  • System Databases
  • User Databases

We will create our own database called StudentDB here.

3. New Query Button

Opens a fresh query tab on the toolbar so you can start typing SQL.

4. Query Editor

The large white workspace area where we type SQL commands.

5. Execute Button

Runs the SQL commands written in the Query Editor (or press F5).

6. Results Window

Appears below the Query Editor and displays the output of SQL queries.

7. Messages Window

Displays execution details, affected row counts, and any error messages.

Keyboard Shortcuts

Shortcut Purpose
F5Execute Query
Ctrl + NNew Query Window
Ctrl + SSave Query
Ctrl + ZUndo
Ctrl + YRedo
Ctrl + CCopy
Ctrl + VPaste

Common Beginner Mistakes

Cannot Connect

  • Ensure SQL Server is installed.
  • Verify the Server Name.
  • Use Windows Authentication.

No Results

  • Remember to click Execute (F5).

Red Underlines

  • Check for spelling mistakes.
  • Ensure SQL keywords are typed correctly.
Class Pop Quiz #3

1. You wrote a query in the Query Editor, but nothing appeared in the Results Window. Which shortcut runs it?

2. Which panel in SSMS acts like the "File Explorer" of SQL Server?

First SQL Command & Practical Exercise

Follow these quick steps inside SSMS to execute your very first SQL commands:

  1. Open SQL Server Management Studio and connect to SQL Server.
  2. Open a New Query window (Ctrl + N).
  3. Run each of the three commands below using F5.
-- 1. Display text
SELECT 'My First SQL Program';

Output: My First SQL Program

-- 2. Display a number
SELECT 100;

Output: 100

-- 3. Display current system date and time
SELECT GETDATE();

Output: 2026-11-24 10:30:45.123 (current system timestamp)

[Pro Tip]: Always wrap text strings in single quotes like 'My First SQL Program'. Numbers like 100 do not need quotes.
Class Pop Quiz #4

What happens if you run SELECT GETDATE(); in SQL Server, and why are parentheses () required?

Answer: It returns the server's current date and time. Parentheses () are required because GETDATE() is a built-in SQL function.

Creating Databases, Tables & Data Types

Creating a Database

Create a new database named StudentDB and switch your active context into it:

CREATE DATABASE StudentDB;
GO

-- Switch context to the newly created database
USE StudentDB;
GO
[Pro Tip]: The USE statement sets the active database for all subsequent queries so your tables are saved inside StudentDB.

Creating a Table

Now create a Students table with four columns and a Primary Key:

CREATE TABLE Students
(
    StudentID INT PRIMARY KEY,
    Name VARCHAR(100),
    Age INT,
    Course VARCHAR(50)
);

Common Data Types Reference

Data Type Used For Example
INTWhole numbers1, 25, 1000
BIGINTVery large whole numbers9999999999
DECIMAL(p,s)Exact decimal values1234.50
FLOATApproximate decimal values98.75
BITBoolean values0 (False), 1 (True)
CHAR(n)Fixed-length textGender = 'M'
VARCHAR(n)Variable-length textName = 'Rahul'
NVARCHAR(n)Unicode text (Telugu, Hindi, etc.)'à°ªూà°°్ణప్à°°à°¸ాà°¦్'
DATEDate only2026-11-24
TIMETime only10:30:45
DATETIMEDate and time2026-11-24 10:30:45
MONEYCurrency values25000.75
Class Pop Quiz #5

1. You want to store student names in Telugu (like 'à°ªూà°°్ణప్à°°à°¸ాà°¦్') or Hindi. Which data type should you pick?

2. Which data type stores Boolean values (0 for False, 1 for True)?

Inserting, Querying, Updating & Deleting Data

Inserting Data

INSERT INTO Students
VALUES (1, 'Rahul', 20, 'Python');

INSERT INTO Students
VALUES (2, 'Anjali', 21, 'SQL');

INSERT INTO Students
VALUES (3, 'Kiran', 22, 'Java');

Querying Data

-- Fetch all columns
SELECT * FROM Students;

-- Fetch only Name and Course
SELECT Name, Course
FROM Students;

Updating Data

UPDATE Students
SET Age = 23
WHERE StudentID = 3;

Deleting Data

DELETE FROM Students
WHERE StudentID = 2;
Crucial Rule: Always use a WHERE clause when updating or deleting to prevent modifying or erasing every row in the table unintentionally.
Class Pop Quiz #6

1. What happens if you run UPDATE Students SET Age = 25; without a WHERE clause?

2. Which query shows only the Name and Course of all students?

Viewing Table Metadata & Dropping a Table

Viewing Table Metadata with sp_help

Run sp_help to inspect a table's columns, data types, indexes, and constraints:

sp_help Students;

Dropping a Table

DROP TABLE Students;

The DROP TABLE statement permanently removes the table and all its data from the database.

Commands Covered Today

CREATE DATABASE USE CREATE TABLE INSERT SELECT UPDATE DELETE DROP TABLE
Final Boss Challenge

You want to check the data types of your Students table, remove Kiran's row, and keep the empty table for future students. Should you use DELETE or DROP TABLE, and how do you inspect the table structure first?

Solution:
1. Run sp_help Students; to inspect the columns, data types, indexes, and constraints.
2. Use DELETE FROM Students WHERE StudentID = 3; to remove only Kiran's row while keeping the table intact.
3. Do not use DROP TABLE Students; because that permanently destroys the entire table structure along with every row.

Your Pop Quiz Score

Answer the clickable quiz questions above to check your score.

0 / 8

Post a Comment

0 Comments