Book review: Transact-SQL Cookbook
Last updated: June 29th '02 | Best viewed with: All popular browsers | Best viewed at: 1024x768 | Links to external sites will open in a new window

About myself
My technical skills
My favorites
My picture album

Shortcut keys
My code library

VB resources
SQLServer resources
SQLServer books
Replication FAQ
Scripting resources
ASP resources

Search my site
Sign my guestbook
Contact information

SQL Server Articles New

Click here to find out the top 15 SQL Server books purchased by this site's visitors! NEW

 
NEW!!! Subscribe to my newsletter:
Want to keep in touch with the latest in SQL Server world? Email vyaskn@hotmail.com with 'subscribe' in the subject line
See also:  
Database coding conventions SQL Server interview questions
Evaluation of federated database servers SQL Server FAQ on programming, administration, replication and tools
SQL Server security best practices SQL Server administration best practices
Related books:
The guru's guide to Transact SQL Advanced Transact-SQL for SQL Server 2000 SQL Server 2000 Programming by example


Title: Transact-SQL Cookbook
Authors: Ales Spetic, Jonathan Gennick
Publisher: O'Reilly & Associates
ISBN: 1565927567
Pages: 302
Click here for more information or to buy this book from: Amazon.com or Amazon.co.uk or Amazon.ca


This is the first 'book review' on my site and it happens to be the most practical Transact-SQL (T-SQL) book I've ever read. I read this book cover to cover and picked up a lot of tips and tricks. Before I start with the 'chapter by chapter' review, let me walk you through the key characteristics of this book.

It is a concise (Hardly 300 pages), practical, no-nonsense book. It assumes that the reader has a basic understanding of T-SQL and it's syntax. So, there's no space wasted on explaining the 'real basics' and T-SQL syntax. Nice 'writing style' and 'simple language' make this book an easy and comfortable read. Each chapter starts with an introduction to the topic followed by problems and solutions and explanations to those solutions. Since this is a cookbook, authors call each solution, a 'recipe'. Topics covered in this book are interesting and appeal equally to the beginner T-SQL programmers as well as the experienced. Start with the first chapter (in which the pivot table technique is introduced), and jump off to any chapter you prefer from then on, as the rest of the chapters are independent of each other.

Chapter 1: Pivot Tables
This chapter introduces you to a very powerful technique of using pivot tables. Not many T-SQL programmers are aware of this technique, and if you are one of those, then it's a must read for you. Some of the solutions proposed in other chapters are based on pivot tables. That's why I said, "start with the first chapter" and it's hardly four pages.

Chapter 2: Sets
This chapter introduces you to the set theory and discusses set operations like Contains, Intersection, Union, Complement, Difference and then shows you how to implement those set operations, with a number of practical examples. If you are an experienced programmer and are able think in terms of sets, then this chapter tends to be a bit of repetition for you. But, if you are a beginner database programmer and are unable to get rid of your procedural coding habits, then this chapter is a life saver for you. It can open your eyes to the power of set oriented operations and help you replace those bulky cursors with efficient set operations.

Chapter 3: Data Structures
Who said data structures can be programmed only in C and C++? This chapter shows you how to implement lists, stacks, queues, arrays and matrices in SQL. Also explains regions, runs and sequences with a lot of examples taken from practical scenarios.

Chapter 4: Hierarchies in SQL
This has always been a very interesting and elusive topic for T-SQL programmers as there's no in-built support for hierarchies (like Oracle's CONNECT BY extension) in Microsoft SQL Server. This chapter discusses generic and specific hierarchies and provides you with T-SQL code to implement a 'permissions hierarchy' for a trading system. Then it offers you the recursive and non-recursive solutions for traversing hierarchies and goes on to discuss the latest technique proposed by Itzik Ben-Gan (SQL Server MVP) for efficiently searching through hierarchies.

Chapter 5: Temporal Data
This chapter shows you how to work with date and time data, intervals, periods, gaps etc. and offers you lots of practical examples. If date operations and date arithmetic stump you often, this chapter is a must read for you and even otherwise, it offers some excellent pieces of code.

Chapter 6: Audit Logging
Audit logging and journaling is another feature that is not built-into SQL Server. Lot of DBAs and programmers have come up with their own auditing implementations and there are a lot of third party tools out there as well. But this chapter shows you all the nitty-gritty involved in implementing your own auditing (using triggers) mechanism. Shows you how to recover lost data from audit logs and how to generate a point-in-time snapshot of data from audit logs.

Chapter 7: Importing and Transforming Data
Yet another interesting chapter that shows you how to import data from heterogeneous, non-normalized data sources like flat files, CSV files etc. into SQL Server, clean the data, handle errors, transform the data and store it in normalized, relational tables. Worth a read if your work requires you to deal with importing data from other data sources.

Chapter 8: Statistics
This chapter delves deep into Statistics, and discusses the calculation of mean, mode, median, standard deviation etc.

Overall, this is a valuable book for beginning-to-intermediate SQL Server programmers and a great reference for experienced database professionals.

Click here for more information or to buy this book from: Amazon.com or Amazon.co.uk or Amazon.ca