Transact-SQL Cookbook

Book Review

Transact-SQL Cookbook
by Ales Spetic & Jonathan Gennick
Copyright 2002
O’Reilly & Associates

Transact-SQL Cookbook Find out more about this book,
or purchase it, from

So you have mastered Transact-SQL, and you know how to SELECT, INSERT, UPDATE, and DELETE data. But, do you know how to create and use a pivot table, how to summarize classes of sets of data, how to find the complement of a set, how to calculate a matrix trace, how to transverse hierarchies recursively, how to derive the first and last dates of a month, how to implement audit logging, how to fold tables, or how to calculate correlations using Transact-SQL?

SQL Server’s Transact-SQL language is very powerful and can accomplish every task just described, and thousands more, assuming you now how to put the pieces of the puzzle together. Most books on Transact-SQL teach you the basics, but neglect to teach you how to apply what you have learned to complex real-world problems. That is why the authors of the Transact-SQL Cookbook decided to write the book they did.

In essence, the Transact-SQL Cookbook is a recipe book on how to perform a wide variety of complex tasks using Transact-SQL. The book’s goal is not to teach you the basics of Transact-SQL (the authors assume you already know the basics). Instead, the book focuses on providing step-by-step examples of how to perform specific tasks in Transact-SQL. Some of these include:

  • Pivot Tables

  • Sets

  • Data Structures

  • Hierarchies in SQL

  • Temporal Data

  • Audit Logging

  • Importing and Transforming Data

  • Statistics in SQL

Each of the major topics (listed above) are covered in detail, showing you how to perform each different type of function.

While the book covers many advanced topics, anyone who knows Transact-SQL basics should have no problem understanding most of the examples in the book. In fact, this book is an excellent book for those new to Transact-SQL as it helps them to better understand how Transact-SQL can be used to solve real-world problems.

From a performance perspective, the authors don’t spend much time of this topic, although it is discussed in several sections for particular examples. I would have liked to see more time spent on how to optimize the tasks they described from a performance perspective. Some of the tasks described can be performance hogs, but again, sometimes this is impossible to avoid. Some tasks are just very processing intensive.

I recommend this book to all those who want to master Transact-SQL and become top-notch developers. Even if you are an experienced Transact-SQL developer, you may discover new things you didn’t know you could do with Transact-SQL from this book. I know I did.


Leave a comment

Your email address will not be published.