Beginning T-SQL 2012

Author: Scott Shaw and Kathi Kellenberger
Publisher: APress
Pages: 433
ISBN: 978-1430237044
Audience: Beginner to intermediate T-SQL developers
Rating: 4.5
Reviewed by: Kay Ewbank

Updated version of a well-regarded earlier book on T-SQL 2008 that now takes account of SQL Server 2012.

The original book was written by Kathi Kellenberger, and this new edition has been updated by Scott Shaw. The authors make good use of examples, and have exercises that you can do to check you’ve understood the concepts. One small niggle is that the exercises say the answers are contained in the appendix, but this has been omitted from the new edition. According to the APress website the appendix is contained in the zipped file containing the source code online, but when I tried downloading it the ZIP file was reported as corrupted. Hopefully APress will sort this out.

 

Banner

 

The book starts with the absolute basics (installing SQL Express, using Management Studio, and the basic concepts of databases). The following chapters take you through T-SQL one step at a time, with chapters on Simple Select queries, using functions and expressions, querying multiple tables, grouping and summarizing, and manipulating data. By chapter 7 the authors have got as far as T-SQL programming logic - variables, If..Else, While, error handling, and temporary tables. There’s a new chapter in this edition on XML that gives a brief but reasonable introduction to working with XML in T-SQL.

Chapter 9 looks at moving logic to the database covering concepts such as table constraints, views, user defined functions, stored procedures and triggers. Given the amount of time many database developers spend working with these features, I think more space could usefully have been taken - a chapter for each wouldn’t have been over the top. However, what is there is well written. Data types get a chapter that essentially covers large-value data types, the more complex data and time types, hierarchyID, spatial data types (Geometry and Geography) and sparse columns. Most of these have been added to SQL Server 2008 and 2012, and the chapter gives ideas on how they are useful as well as how to use them.

The final ‘teaching’ chapter covers advanced queries. It starts with a look at the more advanced uses of common table expressions (CTEs) and how to use them to isolate parts of the query logic. The authors show how this gives you the means to do things such as write recursive queries (if you really want to tie your server in knots). The examples show how you can have multiple CTEs contained in a single statement, and how you can call a CTE multiple times in one statement. This is where T-SQL can get very powerful, and where you can indeed get into a terrible mess. Other examples in the chapter show how you can join a CTE to another CTE, and how to write a recursive query to call itself. There are good descriptions of the Output clause to retrieve result sets, Merge/Upsert to synchronize two tables, and Grouping sets for those occasions when you need to combine different grouping levels in one statement. Pivoted queries are also looked at in reasonable detail so you can create your own pivot tables using T-SQL.

The book closes with a chapter on other resources you can use having read the book - user groups, books, classes, conferences and so on.

This is a very good book. It’s not perfect, but it would be useful all the way from being a complete beginner who’s never written a SQL Select statement all the way through to pivot tables and recursive queries.

 

Banner


Introducing SQL Server 2019 (Packt)

Author: Kellyn Gorman et al
Publisher: Packt Publishing
Pages: 488
ISBN: 978-1838826215
Print: 1838826211
Kindle: B088BNMRQ4
Audience: SQL Server DBAs and Devs
Rating: 3
Reviewer: Ian Stirk

Each new version of SQL Server introduces new features and enhances others. This book aims to discuss some of these [ ... ]



SQL Query Design Patterns and Best Practices

Author: Steve Hughes et al
Publisher: Packt Publishing
Pages: 270
ISBN: 978-1837633289
Print: 1837633282
Kindle: B0BWRD7HQ7
Audience: Query writers
Rating: 2.5
Reviewer: Ian Stirk

This book aims to improve your SQL queries using design patterns, how does it fare? 


More Reviews

Last Updated ( Tuesday, 02 October 2012 )