INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Identity Increment Jumping

Identity Increment Jumping

(OP)
I have a primary key set as int, Is Identity = YES, Identity Increment = 1

I have noticed that the increment went from 49 to 1042 Why ?? Running SQL Server 2012

I have googled and found others having this issue. How do you stop this from happening ?

Any help would be appreciated

Thanks

RE: Identity Increment Jumping

If you googled, you should also have found the reason behind it.
This happens with restarts. SQL Server rather prevents double values than gaps. It's no bug, it's by design.
Does it matter? Typically the values are used for unique keys and you get unique keys.

If it really matters to you, you can use sequences or trace flag 272.
Shedding more light on this: http://sqlblog.com/blogs/kalen_delaney/archive/201...

Bye, Olaf.

RE: Identity Increment Jumping

(OP)
I have one table that I'm returning the Key field back to the user as the document number. I would like those numbers to stay in a sequence if possible and not jump at random.

RE: Identity Increment Jumping

Have you read my answer?

Bye, Olaf.

RE: Identity Increment Jumping

(OP)
Yes I did, thank you. I tried adding the flag 272 to the sql startup but the number still jumped after a restart. I don't need to use the primary key I'm just trying to create some sort of number sequence to give back to the user once the transaction is complete. I just would like those transaction number to stay as close together in sequence as possible.

RE: Identity Increment Jumping

Well, saying this happens "at random" after having read the explanations to me points out you didn't read. You normally won't have crashes and if you shutdown you can do gracefully as Kalen Delaney explains.
You did something wrong if this trace flag didn't help. -t272

As you are on SQL2012, you can also switch to using a sequence: https://msdn.microsoft.com/en-us/library/ff878091(...

Bye, Olaf.

RE: Identity Increment Jumping

Do not use an identity column for sequential numbers. Use a SEQUENCE object with the NOCACHE option.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close