Get a detailed look at the internal architecture of Transact-SQL (T-SQL)\u2014the database programming language built into SQL Server\u2014with this comprehensive, hands-on programming reference.
"/>
Inside Microsoft SQL Server 2008: T-SQL Programming
Itzik Ben-Gan
Dejan Sarka
Roger Wolter
Greg Low
Ed Katibah
Isaac Kunen
Copyright 2009 Dejan Sarka (All); Ed Katibah (All); Greg Low (All); Isaac Kunen (All); Itzik Ben-Gan (All); Roger Wolter (All)
Dedication
To my siblings, Ina & Mickey |
-- Itzik |
Foreword
Let me start with a few words about the lead author of this book, Itzik Ben-Gan. He is a mentor, consultant, presenter, teacher, and writer. All his roles have a common themeMicrosoft SQL Server programming. But waittheres even more: he is an MVP (officially "Microsoft Valued Professional," but often interpreted as Most Valuable Programmer) and a close partner with many SQL Server developers in Redmond, Washington. The combination of these traits puts Itzik into a unique position when writing a book about SQL Server programming. He knows what works and what does not. He knows what performs and what does not. He knows what questions people ask when he is teaching. And he knows what people grasp easily and what they dont when it comes to introducing more complex concepts of SQL Server programming.
Itzik invited several coauthors to write parts of this book. He does not hesitate to tap the resources of the SQL Server development team when it comes to introducing the newest SQL Server technologies. This was the case with spatial data chapter written by Ed Katibah (a.k.a. "Spatial Ed") and Isaac Kunen and with the Service Broker chapter written by Roger Wolter. Dejan Sarka helped with CLR and XML, and contributed the fascinating chapter on temporal support in the relational model, where he pokes at SQL Server developers about usefulness of PACK and UNPACK relational operators still missing in SQL Server. Greg Low untangled the many ways one can go about tracking access and changes to data and metadata. Both Dejan and Greg are SQL Server veterans and Itziks colleagues in Solid Quality Mentors.
I personally believe in hands-on learning when it comes to programming. This book has many examples and they are all presented in a way that allows you to run them on your own SQL Server installation. If you dont have your own SQL Server installation, you can go to http://www.microsoft.com/sql and download the evaluation version of SQL Server 2008 (you must have a Windows Live ID; the evaluation version is Enterprise and it is good for 180 days). Preferably you should be using the Enterprise or Developer edition of SQL Server to run the examples. And no, you dont need to retype all code segments in the book! You can download the source code from http://www.InsideTSQL.com .
If you are new to the SQL language you should start with the earlier published book, Microsoft SQL Server 2008: T-SQL Fundamentals . If you are new to SQL Server but you have used other SQL supporting products you may want to start with the companion book Inside Microsoft SQL Server 2008: T-SQL Querying . But you can jump right into this book as well; it will give you great insight into SQL Serverspecific programming. You can use the examples in the book to find out whether you need to study specific statements where SQL Server has a different implementation from your previous experiences and you can use these books for reference.
Even if you are a seasoned SQL Server developer Im sure this book will show you new and more efficient ways to perform your tasks. For example, I agree with Dejan that there are few CLR UDTs in production systems. And this is not only true for UDTsfew UDFs, triggers, and stored procedures are written in CLR languages. The book provides numerous examples of C# and Microsoft Visual Basic solutions. Most of the examples are presented in both C# and Visual Basic, which are the most popular CLR languages. The authors are careful about CLR recommendations because of performance implications. Itzik not only provides general performance guidelines, but he also tells you how long the alternatives took to execute on his computer. Of course, you will try it on your computer!
Performance considerations are not restricted to CLR. You will find performance improvement tips in every single chapter of this book. For example, in , you will learn when it is better to use temporary tables and when it is better to use table variables. Itzik uses simple examples, interpreting query plans and showing how to use IO counters when comparing different solutions for the same task.
I mentioned that of this book!
I worked with Roger Wolter on the same team when he was responsible for developing the brand new Service Broker in SQL Server 2005. His chapter () is great reflection of his personalitydeep with very accurate details in perfect structure. If you are new to Service Broker you may want to start reading this chapter from the end, where you will learn which scenarios you can use Service Broker with, along with a brief comparison of Service Broker with messaging solutions delivered by Microsoft Message Queue (MSMQ), BizTalk, and Windows Communication Foundation (WCF). Bank Itau in Brazil and MySpace are two examples of SQL Server customers who use Service Broker for very different purposes. Bank Itau uses Service Broker for batch processing. In MySpace, Service Broker creates a communication fabric among hundreds of SQL Servers behind the MySpace.com social networking site.
Im confident you will find this book useful and worth reading whether you are a new or seasoned SQL Server user. It is an invaluable reference for developers, data architects, and administrators.
Lubor Kollar
Group Program Manager
SQL Server Customer Advisory Team
Microsoft, Redmond, Washington U.S.A.
Acknowledgments
Several people contributed to the T-SQL Querying and T-SQL Programming books and Id like to acknowledge their contributions. Some were involved directly in writing or editing the books, whereas others were involved indirectly by providing advice, support, and inspiration.
To the coauthors of Inside Microsoft SQL Server 2008: T-SQL Querying Lubor Kollar, Dejan Sarka, and Steve Kass; and to the coauthors of Inside Microsoft SQL Server 2008: T-SQL Programming Dejan Sarka, Roger Wolter, Greg Low, Ed Katibah, and Isaac Kunen, it is a great honor to work with you. It is simply amazing to see the level of mastery that you have over your areas of expertise, and it is pure joy to read your texts. Thanks for agreeing to be part of this project.
To Lubor, besides directly contributing to the books by writing a chapter for T-SQL Querying and the foreword to T-SQL Programming , you provide support, advice, friendship, and are a great source of inspiration. I always look forward to spending time with youhiking, drinking, and talking about SQL and other things.
To Dejko, your knowledge of the relational model is admirable. Whenever we spend time together I learn new things and discover new depths. I like the fact that you dont take things for granted and dont blindly follow the words of those who are considered experts in the field. You have a healthy mind of your own, and see things that very few are capable of seeing. Id like to thank you for agreeing to contribute texts to the books. Id also like to thank you for your friendship; I always enjoy spending time with you. We need to do the beer list thing again some time. Its been almost 10 years!
Next page