Solved

SQL Server 2012 Identity Column Increases by 1000

Posted on 2015-02-11
10
80 Views
Last Modified: 2015-02-12
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?
0
Comment
Question by:yonbret
10 Comments
 
LVL 65

Expert Comment

by:Jim Horn
ID: 40603470
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
 
LVL 49

Expert Comment

by:Vitor Montalvão
ID: 40603482
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
 

Author Comment

by:yonbret
ID: 40603585
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 49

Expert Comment

by:Vitor Montalvão
ID: 40603597
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
 

Author Comment

by:yonbret
ID: 40603612
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
 
LVL 49

Accepted Solution

by:
Vitor Montalvão earned 500 total points
ID: 40603619
By this article I think it works.
0
 
LVL 69

Expert Comment

by:Scott Pletcher
ID: 40603639
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
 

Author Comment

by:yonbret
ID: 40603659
We sell a low volume, high dollar product so I think we will be alright performance wise, but I will monitor the performance.
0
 
LVL 35

Expert Comment

by:David Todd
ID: 40604071
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
 
LVL 48

Expert Comment

by:PortletPaul
ID: 40605285
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

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question