T-SQL Fundamentals (Microsoft Press)

Author: Itzik Ben-Gan
Publisher: Microsoft Press
Pages: 608
ISBN: 978-0138102104
Print: 0138102104
Kindle: B0BTLBXF8V
Audience: T-SQL developers
Rating: 5
Reviewer: Kay Ewbank

Itzik Ben-Gan is a highly respected Microsoft Data Platform MVP, and the earlier editions of this book were already very good. This edition has been updated to cover recent versions of SQL Server, including SQL Server 2022, and Azure SQL Database.

The book opens with a look at the background to T-SQL querying and programming, both the theoretical background based on set theory and predicate logic, and the practicalities of the SQL Server architecture and use of tables.


Chapter 2 introduces T-SQL through single-table queries. As with other chapters, this chapter lays out the material being introduced, then has a set of exercises and their solutions. Joins are the next topic to be introduced, specifically cross joins, inner joins, composite, non-equi and multi-joins. Outer joins are also covered, with information on including missing values, and filtering attributes from the non-preserved side of an outer join.

Subqueries are the next topic to be considered, including good explanations of the Exists predicate and the problems that you can encounter with Null.

By Chapter 5, Ben-Gan has moved on to table expressions and how to work with CTEs - common table expressions, including using column aliases and arguments. This opening part of the book concluded with a chapter on Set operators - Union, Intersect and so on.

Ben-Gan then moves on to looking at the wider topic of T-SQL for data analysis, and how to achieve this using Window functions, pivoting data, grouping sets and time series. This is followed by a chapter on data modification, with sections and exercises on the various Insert options, Delete, Truncate, Merge and Update.

A useful chapter on temporal tables follows. These are tables with two columns showing how long the row is valid for, with a linked history tables holding the older states of rows that have been modified. Next comes a strong chapter on transactions and concurrency, with a clear discussion of the different options for isolation levels.

A chapter on SQL Graph is new in this edition. SQL Graph was introduced in SQL Server 2017, and Ben-Gan explains the use of specialized node and edge tables to store the data, then goes on to look at the uses of graph modeling, and how to use it to query data.

The final chapter of the book is titled Programmable objects, and it includes discussions of variables, batches, If..Else and While, Cursors, Routines and Dynamic SQL (i.e. Exec).

I'm a fan of Ben-Gan's writing, and this updated edition of a good book reinforces this. The writing is clear, the examples and exercises are well thought out. Personally I'd have liked more on the programming aspects, but any reader of this book would end up with a good working knowledge of T-SQL.

Highly recommended.

To be informed about new articles on I Programmer, sign up for our weekly newsletter, subscribe to the RSS feed and follow us on Twitter, Facebook or Linkedin.


Beginning Rust Programming

Author: Ric Messier
Publisher: Wiley
Date: March 2021
Pages: 416
ISBN: 978-1119712978
Print: 1119712971
Kindle: B08WZ2D7WC
Audience: Developers wanting to learn Rust
Rating: 3
Reviewer: Mike James
Everyone seems to want to know what makes Rust special. Does this book give the answers?

Query Store for SQL Server 2019 (Apress)

Author: Tracy Boggiano & Grant Fritchey
Publisher: Apress
Pages: 234
ISBN: 978-1484250037
Print: 1484250036
Kindle: B07YNL3X4X
Audience: SQL Server DBAs and Devs
Rating: 4
Reviewer: Ian Stirk

This book aims to use Query Store to improve your SQL Server queries, how does it fare?

More Reviews

Related Reviews