Author: Robin Dewson
Publisher: Apress, 2012
Aimed at: Developers wanting to learn SQL Server and T-SQL
Pros: Fairly comprehensive coverage of T-SQL
Cons: Has quite a high percentage of non-developer topics and stops short of CLR
Reviewed by: Kay Ewbank
A book aimed at developers who know how to program, but who don’t know SQL Server. An interesting proposition.
This is the third edition of Robin Dewson's book for developers who are new to SQL Server and the main changes are to add details of SQL Server 2012, and to provide coverage of SQL Server Express. This isn’t particularly a ‘how to write code to drive SQL Server’ book. It does have examples written in T-SQL code, but starts with quite a lot of material on the standard SQL tools and concepts.
After an opening overview chapter, Dewson kicks off with a look at SQL Server Management Studio, the environment used to build SQL Server database solutions. He then talks about database design and creation, looking at the pre-built databases in SQL Server and how to choose the database system type. Topics such as relationships and normalization finish off this chapter. Security and compliance are discussed in chapter 4, which essentially covers logins, roles and users. Dewson next moves on to how to define tables, followed by index creation and creating database diagrams. Backup and recovery and database maintenance each get chapters.
Up till this point in the book Dewson has largely been covering material that is the same whether you’re a developer or not, but from here onwards he begins to include T-SQL code showing how to back up a database (for example) using T-SQL. Interestingly, while he’s covered topics such as relationships and normalization, he hasn’t really explained T-SQL and how the languages you might choose to work with SQL Server as a developer, and what the advantages and drawbacks are. Instead, T-SQL is introduced essentially by saying ‘you can write program code in Query Editor; the program code is called Transact-SQL. Given the author has just spent four pages telling you what buttons to press to use Windows Authentication Mode, the casual introduction to T-SQL seems a bit underwhelming.
Chapter 9 looks at data insertion, deletion and transactions, and from this point on in the book there is more code on view. There’s a chapter on selecting and updating data that introduces the Select statement. Like so much of the book, I found this chapter a bit odd; there was no mention of Group By or Having, but there was extensive coverage of more recent additions to the basic Select statement such as Top n. Poor old Group By and Having don’t even get mentioned for another 150 pages, and then only as part of a chapter called ‘effective coding’. Views are the next topic after selecting data, then there’s a fairly meaty chapter on stored procedures and functions (with security in terms of granting and revoking permissions to run stored procedures thrown in too).
The chapter on essentials for effective coding takes you through variables, temporary tables, aggregate functions, grouping, general functions, and error handling. A chapter on advanced T-SQL and debugging covers statements such as Create Sequence and subqueries, along with some lost souls such as the Apply operator, Common Table Expressions and Ranking. Cursors are introduced in this chapter, but triggers get a full chapter of their own. The book concludes with a chapter on ‘connecting via code’, looking at connecting to SQL Server using Visual Basic for Applications, Visual Studio and Java.
I finished this book still feeling a bit puzzled. I was hoping for a more general developer’s view of SQL Server. There seemed to be a lot of stuff at the front that is fairly irrelevant to developers (or simple enough to pick up). Management Studio doesn’t seem convoluted enough for the level of explanation, and I’d have thought any developer worth their salt would be able to create tables and indexes by just following the samples and wizards in SQL Server. Being realistic, if a would-be developer is going to struggle with Management Studio to the extent of needing to be taken through each individual item on the View menu, will they really cope as a database developer when they hit the genuinely hard stuff?
I also felt a more accurate title would have been "Beginning Developing for SQL Server 2012 in T-SQL". I know how important T-SQL is, but it is just one element of the overall modern SQL development picture. Given the actual title and the inclusion of 'intermediates' as the intended audience according to the cover, I was expecting to read a book explaining how to begin writing code both in and out of SQL Server to make use of SQL Server data, and while I know there are many developers who work purely in T-SQL, there are many who need to be able to include some use of SQL Server in more general code.
I was also expecting the author to start with an explanation of T-SQL, and use the extra space freed up by not covering more ‘administrator’ topics to look in much more detail at some of the more advanced topics such as how to work with SQL from other environments, how to put it all together, or some coverage of the more obscure aspects of SQL Server such as how to work with Reporting Services, MDX, and the BI tools.
There’s a lot of scope in areas like that for developers to add value. More bizarrely, there’s no mention that I could find of SQL CLR (Common Language Runtime), how it fits with the .NET Framework, and the impressive things you can do with it, or even just the basics of how to use it to write stored procedures, triggers or user defined types in languages such as C# or VB.
Overall, the book is a reasonable introduction to T-SQL, and if you’re looking for a book to guide you from installing SQL Server through to writing triggers and cursors in T-SQL, it’s a reasonable choice.