Roadmap › 2. Database, ETL & BI › Step 28
SQL

SQL Server & T-SQL

Database design and normalisation, data types, constraints, joins, subqueries, CTEs, window functions, stored procedures, functions, views, triggers, indexes, execution plans, transactions, isolation levels, locking, error handling and performance tuning.
What it is & where it is used

Microsoft SQL Server is a relational database management system (RDBMS). T-SQL (Transact-SQL) is Microsoft's extension of ANSI SQL with variables, control flow, error handling, stored procedures and more.

The SQL Server family:

ComponentPurpose
Database EngineStores and queries data (OLTP)
SSIS (Integration Services)ETL — see the SSIS course
SSRS (Reporting Services) / Power BI Report ServerPaginated reports
SSAS (Analysis Services)OLAP cubes, tabular models
SQL Server AgentJob scheduling
Azure SQL Database / Managed InstancePaaS versions in Azure

Editions: Enterprise, Standard, Developer (free, full features, non-production), Express (free, limited), and Azure SQL.

SQL statement categories:

CategoryStatements
DDL (Definition)CREATE, ALTER, DROP, TRUNCATE
DML (Manipulation)SELECT, INSERT, UPDATE, DELETE, MERGE
DCL (Control)GRANT, REVOKE, DENY
TCL (Transaction)BEGIN TRAN, COMMIT, ROLLBACK, SAVE TRAN
Versions & history
VersionYearHighlights
SQL Server 20052005CTEs, ROW_NUMBER/ranking functions, TRY...CATCH, SSIS replaces DTS, CLR integration
2008 / 2008 R22008/2010MERGE, DATE/TIME types, table-valued parameters, filtered indexes
20122012OFFSET/FETCH, LAG/LEAD, window frames, SEQUENCE, THROW, TRY_CONVERT, IIF, Always On Availability Groups, columnstore (read-only)
20142014In-Memory OLTP (Hekaton), updatable clustered columnstore
20162016Query Store, temporal tables, JSON functions, Row-Level Security, Dynamic Data Masking, Always Encrypted, STRING_SPLIT
20172017Linux support, STRING_AGG, TRIM, CONCAT_WS, graph tables, adaptive query processing
20192019Intelligent Query Processing (scalar UDF inlining, table variable deferred compilation), Accelerated Database Recovery, UTF-8
20222022Azure Synapse Link, ledger tables, GREATEST/LEAST, DATE_BUCKET, GENERATE_SERIES, IS [NOT] DISTINCT FROM, parameter-sensitive plan optimisation
20252025AI-ready: native vector data type and vector search, native JSON type, regular expression functions (REGEXP_LIKE etc.), optimized locking, Fabric mirroring
Lifecycle

How SQL Server executes a query:

  1. Parse — syntax check, build a parse tree.
  2. Bind (algebrize) — resolve names, types, permissions.
  3. Optimise — the cost-based query optimizer uses statistics to choose an execution plan (join types, index seeks vs scans, parallelism).
  4. Plan cache — plan stored for reuse (parameterised queries reuse plans).
  5. Execute — the storage engine reads pages from the buffer pool (memory) or disk, acquiring locks/latches.
  6. Return results to the client.

Logical query processing order (not the written order):

FROM → ON → JOIN → WHERE → GROUP BY → HAVING → SELECT → DISTINCT → ORDER BY → TOP/OFFSET-FETCH

That's why you can't use a SELECT alias in WHERE, but you can in ORDER BY.

Transaction lifecycle: BEGIN TRAN → statements write to the transaction log first (write-ahead logging) → COMMIT (durable once the log is hardened) or ROLLBACK (undo using the log). Checkpoints write dirty pages to data files; recovery replays/undoes the log after a crash.

Database development lifecycle: requirements → conceptual model (ER diagram) → logical design (normalisation) → physical design (types, indexes, partitions) → implementation (DDL scripts/migrations) → testing → deployment (DACPAC/scripts) → monitoring and tuning → maintenance (backups, index/statistics maintenance).

Tools used to develop
ToolUse
SQL Server Management Studio (SSMS 21)Main admin/dev IDE: queries, execution plans, Agent, backups
VS Code + MSSQL extensionCross-platform editor (Azure Data Studio retired Feb 2026)
SQL Server Data Tools (SSDT) / SQL database projectsSchema as code, DACPAC deployments
sqlcmd, bcpCommand-line scripts and bulk copy
SQL Server Profiler / Extended EventsTracing (Profiler is deprecated; prefer XEvents)
Query StorePlan history, regressed queries, forcing plans
Database Engine Tuning AdvisorIndex suggestions
SQL Server AgentScheduled jobs
sp_WhoIsActive, sp_Blitz (First Responder Kit)Free community diagnostic scripts
Redgate SQL Prompt / SQL Compare, dbForgeProductivity and schema compare
Flyway, DbUp, EF migrationsDatabase migrations