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.

Banner

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.

Banner


Professional C++, 5th Ed (Wrox)

Author: Marc Gregoire
Publisher: Wrox
Date: February 2021
Pages: 1312
ISBN: 978-1119695400
Print: 1119695406
Audience: C++ developers
Rating: 4
Reviewer: Mike James


Professional C++? Who wants to be unprofessional?



SQL Server Advanced Troubleshooting and Performance Tuning (O'Reilly)

Author: Dmitri Korotkevitch
Publisher: O'Reilly
Pages: 497
ISBN: 978-1098101923
Print:1098101928
Kindle: B0B197NYD7
Audience: DBAs & database devs
Rating: 5
Reviewer: Ian Stirk

This book aims to improve the performance of your SQL Servers, how does it fare?


More Reviews

Related Reviews