Solved

SQL Server 2012 Identity Column Increases by 1000

Posted on 2015-02-11
10
72 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 45

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
 
LVL 45

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
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
LVL 45

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:ScottPletcher
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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Introduction SQL Server Integration Services can read XML files, that’s known by every BI developer.  (If you didn’t, don’t worry, I’m aiming this article at newcomers as well.) But how far can you go?  When does the XML Source component become …
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

744 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now