T-SQL Fundamentals Fourth Edition

By: Itzik Ben-Gan
Technical Editor: Lilach Ben-Gan
Publication Date: February 2023
ISBN-13: 978-0-13-810210-4
ISBN-10: 0138102104
608 pages

Order the book at:


Table of Contents

CHAPTER 1: Background to T-SQL querying and programming

CHAPTER 2: Single-table queries

CHAPTER 3: Joins

CHAPTER 4: Subqueries

CHAPTER 5: Table expressions

CHAPTER 6: Set operators

CHAPTER 7: T-SQL for data analysis

CHAPTER 8: Data modification

CHAPTER 9: Temporal tables

CHAPTER 10: Transactions and concurrency


CHAPTER 12: Programmable objects

Appendix: Getting started


This book walks you through your first steps in T-SQL (also known as Transact-SQL), which is the Microsoft SQL Server dialect of the ISO/IEC and ANSI standards for SQL. You’ll learn the theory behind T-SQL querying and programming and how to develop T-SQL code to query and modify data, and you’ll get a brief overview of programmable objects.
Although this book is intended for beginners, it’s not merely a set of procedures for readers to follow. It goes beyond the syntactical elements of T-SQL and explains the logic behind the language and its elements.
Occasionally, the book covers subjects that might be considered advanced for readers who are new to T-SQL; therefore, you should consider those sections to be optional reading. If you feel comfortable with the material discussed in the book up to that point, you might want to tackle these more advanced subjects; otherwise, feel free to skip those sections and return to them after you gain more experience.
Many aspects of SQL are unique to the language and very different from other programming languages. This book helps you adopt the right state of mind and gain a true understanding of the language elements. You learn how to think in relational terms and follow good SQL programming practices.
The book is not version specific, it does, however, cover language elements that were introduced in recent versions of SQL Server, including SQL Server 2022. When I discuss language elements that were introduced recently, I specify the version in which they were added.
Besides being available as an on-premises, or box, flavor, SQL Server is also available as cloud-based flavors called Azure SQL Database and Azure SQL Managed Instance. The code samples in this book are applicable to both the box and cloud flavors of SQL Server.
To complement the learning experience, the book provides exercises you can use to practice what you learn. I cannot emphasize enough the importance of working on those exercises, so make sure not to skip them!

Sample Content

Chapter 01: Background to T-SQL Querying and Programming – Download

Download Source Code

Copyright notice: you’re only authorized to download the source code if you own a legal copy of the book.

Source code for T-SQL Fundamentals 4th Edition

View / Submit Corrections

T-SQL Fundamentals – Submit Errata