Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Identity column gaps

Author  Topic 

binucn
Starting Member

5 Posts

Posted - 2011-04-08 : 01:25:06
Hi,

What are the possible situations for gaps in identity column, other than row deletion


thanks
Binu

nathans
Aged Yak Warrior

938 Posts

Posted - 2011-04-08 : 01:30:45
An error during insert will cause the identity to increment, so subsequent successful inserts would appear to have created a gap.

Nathan Skerl
Go to Top of Page

nigelrivett
Master Smack Fu Yak Hacker

3385 Posts

Posted - 2011-04-08 : 02:58:17
The next identity value is taken from the seed. The seed is updated on execution of an insert (not on completion).
Possibilities are the seed being updated by a dbcc command, an insert with a specific identity value greater than the seed (direction of step), rows being deleted, an insert starting and not being committed,the seed being lost (not so common now).
see
http://www.simple-talk.com/sql/t-sql-programming/identity-columns/

==========================================
Cursors are useful if you don't know sql.
SSIS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

binucn
Starting Member

5 Posts

Posted - 2011-04-11 : 00:29:33
Thank u very much for the replies.



regards
Binu
Go to Top of Page
   

- Advertisement -