THE SQL Server Blog Spot on the Web

Welcome to - The SQL Server blog spot on the web Sign in | |
in Search

Alexander Kuznetsov

My book is complete, many thanks to Hugo, Tony, and many others!

My book is finished.

A couple years ago I googled up "Defensive Database Programming", and came up with nothing. Naturally, I started filling up the void. Although the book is complete, I am planning to continue my research; I would appreciate any other defensive scenarios to discuss and describe.

Many thanks to my longtime friend Hugo Kornelis. I was very lucky that he agreed to review my book; he went very much beyond just reviewing it - his multiple excellent suggestions were invaluable.

Thanks to the brilliant editor Tony Davis, who patiently guided me all the way through.

Maybe we should do it again some time.

Also thanks to everyone who commented on my blog posts, helping me to crystallize and clarify the ideas, around which I eventually wrote my book.


Published Friday, June 18, 2010 3:22 PM by Alexander Kuznetsov



Sankar Reddy said:


How different is the book listed in amazon from the one listed on simple-talk?

A quick look tells me that ISBN numbers are different but the titles are same.

June 18, 2010 4:31 PM

Alexander Kuznetsov said:


The printed/kindle editions have two more chapters:

Ch. 09: Concurrent Queries and Transaction Isolation Levels

A query that works splendidly in isolation can often fail miserably when put to work in

a live OLTP system, with real life concurrency. To make a bad situation worse, in many

cases such errors are subtle and intermittent, and therefore very difficult to reproduce

and understand. This chapter considers the case of reporting queries running against

tables that are being simultaneously modified, demonstrates how inconsistent results

can be returned, assesses the impact of various isolation levels, and considers how best

the defensive programmer can defend data integrity, while minimizing deadlocks.

Ch. 10: Developing Modifications that Survive Concurrency

Just like queries, modifications that work perfectly well in the isolated world of the

test database, can suddenly start misbehaving intermittently when run in a production

environment under conditions of concurrent access. The chapter covers some of the

problems that might occur when "competing" connections try to simultaneously update

the same data, and how to avoid them:

• lost modifications, a.k.a. lost updates – such problems occur when modifications

performed by one connection are overwritten by another; they typically occur

silently, and no errors are raised.

• resource contention errors – such as deadlocks and lock timeouts

• primary key and unique constraint violations – such problems occur when

different modifications attempt to insert one and the same row.

June 18, 2010 4:44 PM

Sankar Reddy said:

Thanks Alex. I will get my copy then. Your work has been invaluable to the community. Great Job.

June 18, 2010 5:45 PM

Alejandro Mesa said:


Congratulations on finishing your book!!!

I already ordered a copy, and I am sure I will enjoy reading it.


June 18, 2010 10:01 PM

James Luetkehoelter said:

Gratz! Having been through the process I know what a feat it is getting something published - looking forward to it!

June 19, 2010 12:25 AM

a.m. said:

Congrats, Alex! I can't wait to check it out.

June 19, 2010 7:22 AM

Aaron Bertrand said:

Thanks Alex!  Just ordered my print copy.

June 20, 2010 10:27 PM

Alexander Kuznetsov said:

Thanks, Sankar, Alejandro, James, Adam, and Aaron!

June 21, 2010 8:11 AM

Piotr Rodak said:

Hey Alex, congrats on finishing the book, great job!


June 21, 2010 3:04 PM

Alexander Kuznetsov said:

Thank you, Piotr!

June 22, 2010 9:45 AM

AaronBertrand said:

Received today.  Flattered to have been mentioned in the acknowledgments.  Thanks Alex!

June 23, 2010 1:20 PM

Madhivanan said:

Congratulations Alex

June 28, 2010 11:15 AM

Robin Cole said:

Alexander, We searched Amazon for the Kindle edition of your book without success?  Is it available there, or can you offer a different source?  Direct from you, maybe?

April 4, 2014 10:38 AM

AlexK said:


I do not think there is Kindle edition.

April 4, 2014 2:02 PM
New Comments to this post are disabled

About Alexander Kuznetsov

Alex Kuznetsov has been working with object oriented languages, mostly C# and C++, as well as with databases for more than a decade. He has worked with Sybase, SQL Server, Oracle and DB2. He regularly blogs on, mostly about database unit testing, defensive programming, and query optimization. Alex has written a book entitled "Defensive Database Programming with Transact-SQL" and several articles on and Currently he works as an agile developer.

This Blog


Privacy Statement