Chapter 11. Transactions and Locks

What to do...? What to do...? This I pondered when considering this chapter. Since I usually teach this topic even to so-called "beginners" (and I have coverage of it in Beginning SQL Server 2008 Programming), I seriously debated removing this subject from the Professional title. The problem with that, however, is that, while fundamental in nature, transactions and locks are a fundamental that even lots of fairly advanced users don't quite "get." You see, while nothing in this chapter is wildly difficult, transactions and locks tend to be two of the most misunderstood areas in the database world.

This is one of those chapters that, when you go back to work, will make you sound like you've had your Wheaties today. As such, this "beginning" (or at least I think it's a basic) concept is going to make you start to look like a real pro.

In this chapter, we're going to:

  • Examine transactions

  • Examine how the SQL Server log and "checkpoints" work

  • Unlock your understanding of locks

Now, lest you think that I've suddenly decided to treat you like a rookie, rest assured, we will look a tad more in depth in several places than I necessarily do for beginning readers.

Transactions

Transactions are all about atomicity. Atomicity is the concept that something should act as a unit. From our database standpoint, it's about the smallest grouping of one or more statements that should be considered to be "all or nothing."

Often, when dealing with data, we want to make sure that ...

Get Professional Microsoft® SQL Server® 2008 Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.