SQL Server seed value lower than max identity -
SQL Server seed value lower than max identity -
i have table contains a column, integer, specified auto-incrementing primary key.
create table [dbo].[table] ( [tablekey] [int] identity(1,1) not replication not null, [...] constraint [pk_tablekey] primary key clustered ( [tablekey] asc ) ( pad_index = off, statistics_norecompute = off, ignore_dup_key = off, allow_row_locks = on, allow_page_locks = on, fillfactor = 80 ) on [primary] ) on [primary] this table has been having anywhere 0 - 7000 records inserted m-f, without issue. lastly fri ~4k records inserted identity values starting @ 2,064,682 , ending @ 2,068,076. morning received error...
violation of primary key constraint 'pk_tablekey'. cannot insert duplicate key in object 'dbo.table'. duplicate key value (2067844).
after going downwards lot of wrong paths found current seed table 2067845.
my question is, because cannot find related, how happen? see, , understand, why may see higher seed max identity, not other way around.
any help appreciated.
sql server 2012 identity column has been problematic ever since release of 2012, skipping identity values, not next seed correctly etc...
you can log bug microsoft @ microsoft connect.
here of other knows bugs logged on connect identity column
identity column jumps seed value
failover or restart results in reseed of identity
also prepare can execute next commands
dbcc checkident('tablename', reseed, 0) --<-- smallest value 0 trick dbcc checkident('tablename', reseed) --<-- without seed value this reseed identity column next available highest identity value. saving future duplicate issues.
sql-server sql-server-2012 identity
Comments
Post a Comment