Helpful Information
 
 
Category: MS SQL Development
Identity not incrementing sequencially

I am looking at a key field set with an auto incrementing identity.

after several inserts from our web form there are gaps in identy number generated. Sometime there are gaps of 2 other times there are gaps of 4.

example if you were to cycle through the identities it goes 13, 14, 17, 18 -- 15 and 16 are missing.

any idea how this could occur?

I have checked logs and found no indication of errors but may not have looked everywhere I need to.

Any suggestions as to where to look for possibly lost inserts as well as a clue as to how it happens would be appreciated!

Thanks!

ESD

I used to live in Kittredge. Is the Little Bear still around?

The likeliest reason for missing identity values is if your code started an insert but didn't finish it, or if a record is deleted after it's inserted.

The identity value won't "back up" to use staggered values.

My recommendation is don't worry about it. Typically an autonumber/identity is nothing but a unique record identifier and shouldn't have any other significance other than it's uniqueness. If you absolutely positively need sequential numbers you might look at an additional column that gets it's value from some process you can control.

When did you leave Kittredge?

The Little Bear is still there hoppin like usual. I think the best seats are still just up above the band, just remember the earplugs!

I kinda thought that was what was happening with the inserts since there is no way for users to delete records. I just needed some reassurance =-))

thanks for the reply.

It's been almost 20 years ago now. I was there for the big blizzard of 1982, snowed in for 1 week! I fondly remember taking maybe 10 minutes to get across the room at the LB. I was there one night when Willie Nelson dropped in and played for a while. This was back before the IRS took his Evergreen ranch. :)










privacy (GDPR)