Skip to content
Tutorials Center
My learning

Topics

SQL Server Tutorial

Learn SQL Server step by step: 39 lessons in 9 chapters with examples, quizzes, diagrams and projects.

Start learning →

of lessons completed

Getting Started

  1. 1 Introduction to SQL Server Learn what Microsoft SQL Server is, how its engine, editions and T-SQL fit together, and how to read your first query before installing anything.
  2. 2 Installing SQL Server and Its Tools Set up SQL Server on Windows, Linux or Docker, choose between SSMS, Azure Data Studio and sqlcmd, connect for the first time and run a test query.
  3. 3 Databases, Schemas and Objects in SQL Server Understand how an instance, databases, schemas, tables and files relate, what the system databases do, and how to create a database and tables in T-SQL.
  4. 4 T-SQL Basics โ€“ Batches, Variables and Control Flow Learn how T-SQL batches work, declare and use variables, print output, branch with IF and loop with WHILE, plus the system functions you will use daily.
  5. 5 SQL Server Data Types Choose the right SQL Server data type: integers, DECIMAL vs FLOAT, VARCHAR vs NVARCHAR, DATETIME2, BIT, UNIQUEIDENTIFIER and implicit conversion rules.

T-SQL Querying

  1. 6 SELECT, TOP and DISTINCT in T-SQL Write T-SQL SELECT queries: choose columns, use aliases, limit rows with TOP and TOP WITH TIES, remove duplicates with DISTINCT and understand logical processing order.
  2. 7 Filtering Rows with WHERE in T-SQL Filter rows in SQL Server with WHERE: comparison operators, AND/OR/NOT, IN, BETWEEN, LIKE wildcards, IS NULL, three-valued logic and writing index-friendly conditions.
  3. 8 Sorting and Paging with ORDER BY, OFFSET and FETCH Sort SQL Server results with ORDER BY, handle NULL ordering and collations, and page through large result sets with OFFSET and FETCH, including keyset paging.
  4. 9 Grouping and Aggregating Data in SQL Server Summarize data with COUNT, SUM, AVG, MIN, MAX, GROUP BY and HAVING, then go further with GROUPING SETS, ROLLUP, CUBE, STRING_AGG and COUNT_BIG in T-SQL.

Functions and Expressions

  1. 10 SQL Server String Functions Master T-SQL string functions: LEN, LEFT, SUBSTRING, CHARINDEX, REPLACE, TRIM, CONCAT, STRING_SPLIT, FORMAT and pitfalls such as trailing spaces and NULL concatenation.
  2. 11 SQL Server Date and Time Functions Work with dates in SQL Server: SYSDATETIME, DATEADD, DATEDIFF, DATEPART, EOMONTH, DATETRUNC, time zones and safe date range filters, with portable stand-ins.
  3. 12 Conversion and Numeric Functions in SQL Server Convert types safely with CAST, CONVERT and TRY_CAST, round and truncate numbers with ROUND, CEILING and FLOOR, avoid integer division and use RAND and ABS.
  4. 13 Conditional Expressions: CASE, IIF, COALESCE and ISNULL Add logic to queries with CASE, IIF, CHOOSE, COALESCE, ISNULL and NULLIF, learn how NULLs flow through them and use CASE for conditional aggregation and custom sorting.

Joins, CTEs and Window Functions

  1. 14 Inner and Outer Joins in SQL Server Combine tables with INNER, LEFT, RIGHT and FULL OUTER JOIN in T-SQL, learn ON versus WHERE for outer joins, join on multiple keys and find unmatched rows.
  2. 15 CROSS JOIN, Self Joins and APPLY in T-SQL Learn CROSS JOIN for combinations, self joins for hierarchies, and T-SQL's CROSS APPLY and OUTER APPLY to run a correlated table expression per row, such as top N per group.
  3. 16 Set Operators and Subqueries in SQL Server Combine result sets with UNION, UNION ALL, INTERSECT and EXCEPT, and nest queries with scalar, IN, EXISTS and correlated subqueries and derived tables in T-SQL.
  4. 17 CTEs and Recursive Queries in SQL Server Write readable queries with common table expressions (WITH), chain several CTEs, update through a CTE and walk hierarchies with recursive CTEs, MAXRECURSION and cycle protection.
  5. 18 Window Functions in SQL Server Use SQL Server window functions: OVER, PARTITION BY, ROW_NUMBER, RANK, DENSE_RANK, NTILE, LAG, LEAD, running totals and frame clauses, with live examples.

Data Modification and Transactions

  1. 19 INSERT, UPDATE and DELETE in T-SQL Change data in SQL Server with INSERT, UPDATE, DELETE, TOP, OUTPUT and SELECT INTO. Learn the T-SQL extras, batch deletes and safe habits, with runnable stand-ins.
  2. 20 MERGE in SQL Server Use SQL Server MERGE to insert, update and delete in one statement, see why many teams prefer update-then-insert patterns, and practice the idea with runnable stand-ins.
  3. 21 Transactions and Error Handling in T-SQL Group SQL Server statements into transactions with BEGIN TRAN, COMMIT and ROLLBACK, handle errors with TRY...CATCH and THROW, and use XACT_ABORT and savepoints safely.
  4. 22 Isolation Levels, Locking and Deadlocks Understand SQL Server locking, the five isolation levels, READ_COMMITTED_SNAPSHOT, snapshot isolation, blocking and deadlocks, with a simulated stand-in you can run.

Procedures, Triggers and Functions

  1. 23 Variables and Control Flow in T-SQL Learn T-SQL programming basics for SQL Server: DECLARE and SET, batches with GO, IF...ELSE, WHILE, BEGIN...END, temp tables and table variables, with runnable stand-ins.
  2. 24 Stored Procedures in SQL Server Create and call SQL Server stored procedures with parameters, OUTPUT values, return codes, default values and error handling. Learn plans, permissions and best practices.
  3. 25 User-Defined Functions in SQL Server Write SQL Server user-defined functions: scalar, inline table-valued and multi-statement functions. Learn APPLY, schema binding and why scalar UDFs can slow queries.
  4. 26 Triggers in SQL Server Learn SQL Server triggers: AFTER and INSTEAD OF DML triggers, the inserted and deleted tables, auditing, DDL and logon triggers, and the mistakes that make triggers slow.
  5. 27 Dynamic SQL and Cursors in T-SQL Build SQL strings safely with sp_executesql and QUOTENAME, avoid SQL injection, and learn when a cursor is justified and how to replace most cursors with set-based code.

Indexes and Performance

  1. 28 Clustered and Nonclustered Indexes Understand how SQL Server stores tables as heaps or clustered B-trees, how nonclustered indexes and key lookups work, and how to choose index keys, with runnable plan examples.
  2. 29 Covering Indexes, INCLUDE and Sargability Remove key lookups with covering indexes and INCLUDE columns, write SARGable predicates that can seek, and learn implicit conversion pitfalls, with runnable plan demos.
  3. 30 Execution Plans and Statistics Read SQL Server execution plans: scans, seeks, joins, estimated versus actual rows, STATISTICS IO and TIME, how statistics drive the optimizer and how to fix bad estimates.
  4. 31 Query Store and a Tuning Workflow Find slow queries with Query Store and dynamic management views, force plans, track waits, and follow a repeatable tuning workflow for SQL Server from symptom to fix.

Administration and Security

  1. 32 Backup, Restore and Recovery Models Protect SQL Server data with full, differential and transaction log backups, choose a recovery model, restore to a point in time, verify backups and plan RPO and RTO.
  2. 33 Logins, Users, Roles and Permissions Learn the SQL Server security model: logins versus database users, fixed and custom roles, GRANT, DENY and REVOKE, schemas, ownership chaining and least-privilege design.
  3. 34 Encryption, Masking, Row-Level Security and Auditing Protect SQL Server data with TDE, Always Encrypted, dynamic data masking, row-level security and auditing. Learn what each feature defends against and where it falls short.
  4. 35 SQL Server Agent, Maintenance and Monitoring Automate SQL Server with SQL Server Agent jobs, schedules and alerts. Learn index rebuild versus reorganize, statistics updates, CHECKDB, Database Mail and a monitoring checklist.

Projects and Practice

  1. 36 Project: Order Management Database Build an order management database step by step: schema and constraints, placing orders atomically, stock control, reporting queries and the T-SQL procedure behind each step.
  2. 37 Project: Inventory with an Audit Trail Build an inventory system with stock movements, a derived stock level, low-stock alerts and an automatic audit trail, with T-SQL triggers and runnable portable versions.
  3. 38 SQL Server Practice: Exercises with Solutions Practice SQL Server skills with graded exercises on filtering, grouping, window functions, data changes, transactions, triggers and indexes. Every exercise has a runnable solution.
  4. 39 SQL Server Interview Questions and Answers Prepare for SQL Server interviews with clear answers on T-SQL, joins, indexes, transactions, locking, performance tuning, backups and security, plus coding questions you can run.