on 2 March 2015
I had been an Access programmer for several years (where you do QBE - Query By Example). Although you can do some very powerful and sophisticated SQL in MS Access, it is non-standard (in a bad way) and because of the empahsis on the grid you never really learn how to type SQL, which I think is essential to understanding it properly.
I later got an MCSD with a module in SQL Server but I still felt that my SQL was not really that secure.
I've read many books on SQL and on SQL server over the years. Most are absolutely awful. They are either too complex, or too tricksy or too niche. John J. Patrick wrote a very good book on Access/Oracle SQL and I learned a fair bit from that.
Then I bought this book.
It is a technical masterpiece. Everything is introduced in the right sequence, to the right depth and with crystal clarity.
It's also a tutorial, which I love. You download the sample Database from Itzik's website, install it on your SQL server and then every single thing he discusses is something you can try out.
Every chapter ends with a set of excercises, which I really urge you to do and not cheat on. If you were really paying attention you can solve nearly all of them.
Although this book, is not full of recipes and highly complex solutions, it does contain rock-solid fundamentals that put you in the driving seat for when you want to really push the boat out.
I think it's one of the best technical books I've ever read, it is a joy to read and it opens up the heart and soul of SQL from a real master.
After reading this book (about 4 times).
I type out all my SQL, and I'm really able to get solid answers to my queries.
Finally. I got a job recently where I had to use Oracle. I had worried that this might prove to be a difficult cross-over, however in practice, once your SQL is solid, you can program any database. I'm not talking here about PL/SQL vs T-SQL, only the standard SELECTs and UPDATE/INSERT which are covered brilliantly in this book and apply to all major RDBMS.
on 12 July 2012
Is it a brave move to produce a book on MS SQL in these times? The thought-leaders are all about big data on the network and sqlLite on the device. Or is now the time of the noSql backlash?
Ben-Gan kicks off with a roundup of set theory, the way sql is non-procedural, and even the famous early days of hyprid industry / academics Codd and Date and `third normal form'. Interesting, evocative, and possibly quite useful as background to the way the sql programmer must think.
Then straight into the commands, their application, variance between sql versions, and various gotchas. Whether you find this more or less useful than the online SQL books at msdn.com, probably depends on your preferred learning mode. There are even excercises after each chapter, like in a school book. But I cannot imagine many people would go to the trouble of learning SQL fundamentals without real-world use cases of their own.
His descriptions are absolutely accurate, to my knowledge. The only single challenge I would make, based on my many years of experience with Microsoft SQL server, is to his assertion that online transactional processing and datawarehousing are best kept separate. In fact the superb query optimisation and parallel access handling of MS SQL server has made that untrue long ago.
The debugging tips puzzled me at first: how can a set-based data manipulation language have bugs? Then I remembered my first few long-ago struggles with some of the more complex ways of joining data sets. The issues would almost always revolve around the use of `null' and its non-intuitive behaviour in logical expressions. If Ben-Gan's advice saves you even a few hours of surfing to resolve such questions, you will have paid for the book.
There is even a section on set up and installation but not back-up strategies. My advice: the database server is SO important that you should either plan everything bottom up round your backup and recovery plans - or keep out of this side altogether and get a provider to take responsibility.
He also runs over locking, deadlocks, trouble shooting and isolation levels. But not the real-life key factors in all this, which is the habits and interoperability of different applications that will be accessing the sql server.
SQL server is a work-horse: far superior to mySql in my opinion and still well worth basing your enterprise-grade applications around. I have been running a business 24/7 on an SQL server non-stop for well over a decade under constant access from websites, internal applications and, yes, even entry-level programmers using fundamental T-SQL. Definitely here to stay for some years yet and a technology you should know.
on 18 March 2016
I bought this book along with the official 70-461 training. The 461 training kit is all you need for the exam but this book did fill a few gaps (such as the existence of intersect / except all, which is in the Sql standard but not yet implemented in t-sql). I feel the book is a layed back, laymans read, the 461 training is much more formal, technical and in depth. Both books complement each other, maybe this was the intention, so I would recommend both. This as well as the system internals book by Kalen Delaney. But a good book and a great read, but not essential for the 70-461 exam in my opinion, which I passed recently, yaay.
on 17 November 2014
I have written a detailed chapter-by-chapter review of this book on www DOT i-programmer DOT info, the first and last parts of this review are given here. For my review of all chapters, search i-programmer DOT info for STIRK together with the book's title.
A well-known SQL Server expert explains the fundamentals of T-SQL, how does he fare?
The author is well-known for explaining advanced SQL concepts in a clear manner, often providing useful tips along the way. His aim here is to explain the basics of T-SQL while incorporating good programming practices. Although the code relates specifically to SQL Server 2012, much of it is applicable to earlier and later versions, helpfully Itzik Ben-Gan typically identifies the version association with a T-SQL feature. There are some advanced areas included but they are separated out and can be read later.
Chapter 1 Background to T-SQL Querying and Programming
The chapter opens with a look at the theoretical background of SQL, introducing SQL in the context of the relational database. SQL is a declarative language (i.e. you say what you want to do, not how you want to do it), and T-SQL is Microsoft’s version of SQL. The section continues with a brief look at Data Definition Language (DDL), Data Manipulation Language (DML), and Data Control Language (DCL).
The basics of set theory are introduced, together with predicate logic (true/false). The relational model is explained in terms of propositions, predicates, and relations (i.e. tables). The importance of missing values (nulls), constraints (e.g. foreign keys) and normalization (first, second and third normal forms), are all briefly discussed. The section ends with a quick look at the life cycle of data.
The chapter proceeds with a look at SQL Server Architecture. The different flavours of SQL Server are discussed, in terms of where they run i.e. appliance, box or cloud. The concept of SQL Server instances (having multiple independent SQL Server instance on the same server/box) is discussed, with an instance being the container for one or more databases. The various system databases (master, resource, model, tempdb, and msdb) are briefly explained. The physical set up of a database (filegroups, primary, secondary and log files) are briefly examined.
The final section looks at the tables within the database that contain the actual data. Scripts are provided to create tables, and their content and structure is explained. Coding style is briefly mentioned (e.g. use white space, follow conventions). The chapter ends with a look at data integrity, examining primary keys, foreign keys, check constraints and defaults.
This chapter provides a good introduction to SQL/T-SQL, database theory, sets, normalization, constraints, SQL Server architecture etc. There’s a useful point about not relying of the use of default values. This chapter covers a lot of ground, all of it is important, however I don’t know if it should be introduced to a beginner at the start of the book. In many ways I feel chapter 2 is the real start of the book, I wonder how many absolute beginners will give up after reading this first chapter.
This book aims to provide an introduction to T-SQL. It tackles this objective in a clear manner, providing helpful discussions, relevant example code, useful diagrams, and plenty of related tips. Each chapter ends with a series of exercises and worked example solutions that will enable you to check and expand further on what has been learned.
Since the book is introductory, in many ways it is version independent. Although aimed at SQL Server2012, most of it is applicable to earlier and later versions. In addition to being instructive, the examples provided can be used later to check syntax, and can also form the basis of your own code.
The one problem I had with the book was its first chapter. The chapter is certainly required, but I wonder if it is too advanced/theoretical to be introduced at the start of the book, perhaps preventing absolute beginners from reading further.
If you’re new to T-SQL, I can certainly recommend this very instructive book.