Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

My question is simple: What are the differences / similarities / cardinalities between

  • Transactions
  • Batches
  • Connections and
  • Statements

in SQL Server?

As far as I understand a connection is a single communications channel between a SQL Server instance and a client within which collections of statements grouped as batches are executed. A batch is either implicitly or explicitly mapped to one or several transactions. Is this correct?

share|improve this question
up vote 2 down vote accepted

Pretty much.

A batch is just that, a batch of commands that need to be executed. A transaction is a set of commands that are guaranteed to succeed or fail totally (i.e it won't complete half the commands and then fail on the rest, if one fails they all fail).

As far as I am aware SQL Server makes use of connection pooling so I wouldn't rely on the one connection per client idea.

share|improve this answer
So what's the cardinality between batch and transaction? Is it possible to have multiple batches per transaction? How about vice versa? – Sleepless Mar 30 '10 at 9:19
As far as I am aware it is possible to have multiple transactions per batch but it is not possible to have multiple batches per transaction. – Cromulent Mar 30 '10 at 10:32

Batches and transactions exist at the same level. A batch is a collection of otherwise unrelated SQL commands. A transaction is a collection of SQL commands that operate (as far as all other users of that database are concerned) as one statement.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.