SQL Server 2012 Identity Column Increases by 1000

I have several SQL Server databases. I have hundreds of tables that use an Identity on the primary key to increment the value.

I upgraded to SQL Server 2012 about 6 months ago. Twice since the upgrade, my Identity value has jumped by around 1000.

I have hundreds of tables that use the identity column, but the jump has only occurred on a couple of the higher use tables. For example, the Return Order table, has twice jumped by around 1000 places.

As a programmer, a number is a number and I could really care less, but the end users don't like to see that two sequential orders are numbered 8001 and then 9001.

Can anyone explain why this is happening and what can be done to prevent it in the future?
yonbretAsked:
Who is Participating?
 
Vitor MontalvãoConnect With a Mentor MSSQL Senior EngineerCommented:
By this article I think it works.
0
 
Jim HornMicrosoft SQL Server Developer, Architect, and AuthorCommented:
The most likely cause is that rows were inserted between 8001 and 9000 and then deleted.
Identity values do not automatically 're-seed' when rows are deleted.

Just out of curiosity, explain why users are seeing this id field, and why they would care?  
The answer will affect a couple of workarounds we can provide.
0
 
Vitor MontalvãoMSSQL Senior EngineerCommented:
orders are numbered 8001 and then 9001.
Is just a guess but can be a composed value here? Like 8 + 001 and 9 + 001?
Another guess is there is some process that insert and then deletes some rows and being an identity column will let gaps.
You can post here the table definitions so we can see better how we can help you.
0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
yonbretAuthor Commented:
They are not deleted rows and are not composed values.

I found this article on the issue, but I want some confirmation that this solution will actually work:

http://www.codeproject.com/Tips/668042/SQL-Server-Auto-Identity-Column-Value-Jump-Is
0
 
Vitor MontalvãoMSSQL Senior EngineerCommented:
Very interesting. Specially the part "Microsoft declares it is a feature rather than a bug and in many scenarios it would be helpful."

First time I'm hearing this. But SEQUENCES are a good solution. It's been used by ORACLE for years already.
0
 
yonbretAuthor Commented:
Has any one used the -t272 option found in the article?

I don't have the time to transform hundreds of identity columns to sequence columns.
0
 
Scott PletcherSenior DBACommented:
You need to fully understand the performance hit you're taking by doing this.

You'd be better off telling the users that it's just an arbitrary number and that it's never guaranteed to be truly sequential.

Rollbacks can also cause gaps in the numbers, although a rollback of 1000 rows would be unheard of for a lot of tables.
0
 
yonbretAuthor Commented:
We sell a low volume, high dollar product so I think we will be alright performance wise, but I will monitor the performance.
0
 
David ToddSenior DBACommented:
Hi,

I have a small database with a table or two with identities. I've seen this occur when moving the database between workstations, or upgrading it.

That would fit with your comment that you upgraded 6 months ago.

HTH
  David
0
 
PortletPaulCommented:
It absolutely should not matter, to any human, if there are non-contiguous unique identities.
If humans seriously do get upset by this there is a design fault.

On your own head be it, I vote against.
0
All Courses

From novice to tech pro — start learning today.