Press "Enter" to skip to content

Gaps in Identity Columns

Josh Simar doesn’t like gaps in identity columns brought about by rollbacks:

At the end of this you can see that those records were in the table before the rollback as evidenced by the now 2000 records in the table. However we ran our identity checker after the rollback and we’ll see some interesting results because of that.

Checking identity information: current identity value '2000', current column value '1000'. DBCC execution completed. If DBCC printed error messages, contact your system administrator.

The rollback did absolutely nothing for our identity and left it as is.

The short answer is that this is expected and reasonable behavior. Don’t expect identity integers to be sequential; the best you’ll get (assuming no resets or overflows) is a guarantee that they’ll be monotonically increasing. I left the long answer as a comment, currently awaiting moderation.