Buy new:
Save with Used - Good

Download the free Kindle app and start reading Kindle books instantly on your smartphone, tablet, or computer - no Kindle device required.
Read instantly on your browser with Kindle for Web.
Using your mobile phone camera - scan the code below and download the Kindle app.
Defensive Database Programming with SQL Server
Purchase options and add-ons
- ISBN-101906434492
- ISBN-13978-1906434496
- PublisherRed Gate Books
- Publication dateMay 31, 2010
- LanguageEnglish
- Dimensions6.14 x 0.81 x 9.21 inches
- Print length394 pages
Frequently purchased items with fast delivery
Editorial Reviews
About the Author
Alex has written multiple articles on simple-talk.com and devx.com, and contributed a chapter to "MVP Deep Dives" book. Currently he works with DRW Trading Group in Chicago, where he leads a team of developers, practicing agile development, defensive programming, and database unit testing every day. In his leisure time Alex prepares for and runs ultramarathons.
Product details
- Publisher : Red Gate Books
- Publication date : May 31, 2010
- Language : English
- Print length : 394 pages
- ISBN-10 : 1906434492
- ISBN-13 : 978-1906434496
- Item Weight : 1.24 pounds
- Dimensions : 6.14 x 0.81 x 9.21 inches
- Best Sellers Rank: #4,179,971 in Books (See Top 100 in Books)
- #583 in SQL
- #4,587 in Computer Programming Languages
- #11,306 in Programming Languages (Books)
- Customer Reviews:
About the author

Discover more of the author’s books, see similar authors, read book recommendations and more.
Customer reviews
- 5 star4 star3 star2 star1 star5 star63%37%0%0%0%63%
- 5 star4 star3 star2 star1 star4 star63%37%0%0%0%37%
- 5 star4 star3 star2 star1 star3 star63%37%0%0%0%0%
- 5 star4 star3 star2 star1 star2 star63%37%0%0%0%0%
- 5 star4 star3 star2 star1 star1 star63%37%0%0%0%0%
Customer Reviews, including Product Star Ratings help customers to learn more about the product and decide whether it is the right product for them.
To calculate the overall star rating and percentage breakdown by star, we don’t use a simple average. Instead, our system considers things like how recent a review is and if the reviewer bought the item on Amazon. It also analyzed reviews to verify trustworthiness.
Learn more how customers reviews work on AmazonTop reviews from the United States
There was a problem filtering reviews. Please reload the page.
- Reviewed in the United States on April 13, 2011Format: PaperbackVerified PurchaseI was at a presentation by the author about this subject last year (March 2010) even before the book was published. Unfortunately, the book was not published until several months later. If I recall correctly, I ordered it on a pre-release basis. I have not been disappointed.
If you go through the book you will very likely find reference to oversights that you may have made in the past and how to avoid them in the future.
The only negative I can say about the book is that I wish that it had more of the author's helpful hints. A good subject, perhaps, for a Volume 2.
By the way - where did the author get that beautiful cover photo? Where was it taken?
- Reviewed in the United States on October 21, 2010Format: PaperbackVerified PurchaseI really enjoyed reading "Defensive Database Programming with SQL Server", and I would recommend it to any SQL Server developer. My favorite chapter was "Chapter 7: "Advanced Use of Constraints", where the author demonstrates the power of the declarative part of the model.
This is not a book for beginners that want to learn about T-SQL language, but if you are already familiar with the language then you will learn about best practices for making your program more robust.
Walk with the author through those situations that can make your code to break. Being aware of these situations is a good start, learning how to defend your code from them is what this book is all about.
- Reviewed in the United States on January 28, 2011This is excellent work on a very important topic. Defensive programming is very often misunderstood, especially in the database world.
Alex deals with this "inconvenient" topic using very practical approach. Instead of filling pages with theory and reasons why defensive programming is good, he dives right into simple examples from the daily work of every database professional. We have all seen (and ignored) many of these issues, but demonstrating how this affects our code and how simple it is to avoid these problems makes this book shine. It is not a complete catalog of defensive techniques, rather a good collection of examples to illustrate the need for defensive coding and applicable methods. It builds the mindset to think proactively and create robust solutions.
The book includes coverage of the following topics: basic defensive technique, code vulnerabilities, changes to database objects, upgrades, reusing code, data integrity and constraints, error handling, concurrency.
"Defensive Database Programming with SQL Server" should be required reading for all SQL practitioners.
- Reviewed in the United States on June 16, 2010I have worked with SQL Server as a developer and a programmer for over 15 years so I have read a lot of books about the product and T-SQL. This is one of the most informative books I have read on SQL in a long time because it made me think a little differently when looking at code. It presented me with situations I haven't seen before (for example a connection setting it's own rowcount explicitly) and the implications that could have.
It really makes you think about the what-if, what happens if your caller does something unexpected and what you might do to mitigate this risk. There are not a whole lot of SQL Server programming books that I learn something from anymore, this was one of them.
- Reviewed in the United States on November 14, 2010This is a great book to read for all levels, as it exposes techniques to test and defend against common mistakes and vulnerabilities that TSQL lends itself too. The book provides lots of example code that you can walk through to get the hands-on experience, to prove to yourself how the code works. The book also offers some brevity, so that you can quickly move through the chapters. One of the parts I enjoyed was the explanation of triggers, constraints and when different situations call for using them. Another chapter of interest was the Defensive Error Handling, which shows some of the limitations of the Try Catch error handling in SQL Server 2005 and 2008. Overall, I found this book to be very helpful and I will begin using some of the takeaways I found immediately.
Top reviews from other countries
- PWReviewed in the United Kingdom on February 13, 2014
4.0 out of 5 stars A valuable read for experienced SQL developers
Format: PaperbackVerified PurchaseDefensive programming is not a new idea but has been around for 30+ years. This book applies the tenets of it to database programming to produce more robust code that is safe to run in unexpected situations.
The subject of this book is to some degree also covered in other books on SQL development, where authors usually recommend to avoid 'risky' practices that might unexpectedly break one day, e.g., after an update of server software. However, it's usually not covered at depth because it's a rather special subject that will mainly appeal to expert developers who have already mastered all the basics of SQL and database programming.
The book focuses on a special, advanced subject, and therefore it is most useful for experienced SQL developers. In it the author looks into a number of typical pitfalls that most SQL programmers will experience the hard way one day in their careers. He offers valuable, practical advice how to avoid these pitfalls before they hurt. The text is well-written and clearly the author knows the subject very well and has significant experience in the field. Some of the practices highlighted in this book and discouraged as 'potentially risky' by the author are of the type that a 'good' programmer will not do anyway. As I myself know only too well often this is more inspired by gut-feeling than really solid knowledge, experience or systematic experimentation.
This book fills the gap between gut-feeling and knowledge in selected areas of SQL development by pointing out why the gut-feeling is indeed justified, why and in what way the practices are potentially problematic, what their impact may be if things go wrong, and how the risk can be avoided and at what price.
In my view the book will be a valuable read for most experienced SQL developers.