Master SQL Server From Scratch

Clear, interactive, and structured SQL Server lessons designed for beginners and developers.

COURSE SYLLABUS
1. Introduction to SQL Server
Introduction to SQL Server SQL Server Installation SQL Server Fundamentals
2. Data Types
Data Types Numeric Data Types Character & String Data Types Date & Time Data Types Other SQL Server Data Types
3. Database & Tables
Database & Tables Introduction Creating a Database Creating Tables Table Structure Altering Tables Dropping Tables
4. Constraints
Constraints Introduction PRIMARY KEY FOREIGN KEY UNIQUE Constraint NOT NULL & DEFAULT CHECK Constraint
5. SQL Basics
SQL Basics Introduction SQL Commands SQL Command Categories SELECT Statement INSERT, UPDATE & DELETE
6. CRUD Operations
CRUD Operations Introduction INSERT Operation SELECT Operation UPDATE Operation DELETE Operation
7. SQL Queries
Queries Introduction WHERE Clause ORDER BY Clause DISTINCT LIKE Operator IN, BETWEEN & IS NULL
8. Joins
Joins Introduction INNER JOIN LEFT JOIN RIGHT JOIN FULL OUTER JOIN CROSS JOIN
9. SQL Functions
SQL Functions Introduction String Functions Numeric Functions Date & Time Functions Conversion Functions NULL Functions
10. Grouping & Aggregate Functions
GROUP BY Aggregate Functions COUNT() SUM() AVG() MIN() & MAX()
11. Subqueries
Subqueries Introduction Single-Row Subquery Multiple-Row Subquery Correlated Subquery Subquery with DML
12. Views
SQL Views Introduction Creating a View Updating a View Altering a View Dropping a View
13. Stored Procedures
Stored Procedures Introduction Creating a Stored Procedure Input Parameters Output Parameters Executing & Modifying Stored Procedures
14. Triggers
Triggers Introduction AFTER INSERT Trigger AFTER UPDATE Trigger AFTER DELETE Trigger INSTEAD OF Trigger
15. Transactions
Transactions Introduction COMMIT ROLLBACK SAVEPOINT Transaction with TRY...CATCH
16. Indexes
Indexes Introduction Clustered Index Non-Clustered Index Creating & Dropping Indexes Index Performance
17. Common Table Expressions
CTE Introduction Simple CTE CTE with JOIN CTE with Aggregate Functions Recursive CTE
18. Window Functions
Window Functions Introduction ROW_NUMBER() RANK() and DENSE_RANK() LEAD() and LAG() PARTITION BY
19. Advanced SQL
Advanced SQL Introduction Temporary Tables Table Variables Dynamic SQL Error Handling Performance Optimization

Table Structure

A SQL Server table is made up of columns and rows. Each column defines the type of data that can be stored, while each row represents a complete record.

Understanding Table Structure

Consider the following Students table:

StudentId StudentName Age Course
1 Samadhan 22 Java
2 Samiksha 21 .NET
3 Pradnya 23 Python

Table Structure Diagram

SQL Server
Students Table
│
├── Columns
│   ├── StudentId
│   ├── StudentName
│   ├── Age
│   └── Course
│
└── Rows
    ├── Record 1
    ├── Record 2
    └── Record 3

Columns

A column represents a particular type of information in a table. Each column has a name and a data type.

Column Data Type Description
StudentId INT Stores the student identifier.
StudentName VARCHAR(100) Stores the student name.
Age INT Stores the student's age.
Course VARCHAR(50) Stores the course name.

Rows

A row represents one complete record in a table.

SQL
1 | Samadhan | 22 | Java
2 | Samiksh | 21 | .NET
3 | Pradnya  | 23 | Python

In the above example, each line represents one student record.

Data Types in Table Structure

Every column should have an appropriate data type. The data type determines what kind of value can be stored in the column.

Data Type Example Common Usage
INT 100 Numbers
VARCHAR 'Rahul' Text
DATE '2026-10-02' Date values
DECIMAL 45000.50 Precise numeric values
BIT 1 / 0 True / False type values

Creating a Table Structure

The table structure is defined while creating the table.

SQL
CREATE TABLE Students
(
    StudentId INT,
    StudentName VARCHAR(100),
    Age INT,
    Course VARCHAR(50)
);

View Table Structure

The sp_help system stored procedure can be used to view information about a table.

SQL
EXEC sp_help 'Students';

View Columns Using INFORMATION_SCHEMA

We can also use INFORMATION_SCHEMA.COLUMNS to retrieve column information.

SQL
SELECT
    COLUMN_NAME,
    DATA_TYPE,
    CHARACTER_MAXIMUM_LENGTH
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = 'Students';

Example Output

Column Name Data Type Length
StudentId int NULL
StudentName varchar 100
Age int NULL
Course varchar 50

Table Structure Flow

SQL Server
Table
  ↓
Columns
  ↓
Column Name + Data Type
  ↓
Rows
  ↓
Records / Data
Important

A well-designed table structure should use meaningful column names and appropriate data types for the data being stored.

Summary

In this section, we learned about the structure of a SQL Server table, columns, rows, data types and different ways to view the structure of a table.