Solved

SQL Server 2012 Identity Column Increases by 1000

Posted on 2015-02-11
10
90 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
10 Comments
 
LVL 66

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 51

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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 51

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 51

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 49

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

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

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

For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties

623 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