Attempt to insert duplicate identity values in table (has identity and key fields)

Attempt to insert duplicate identity values in table (has identity and key fields)

Post by Cyprian Liber » Fri, 10 Sep 1999 04:00:00



I have set up my tables to have auto-generated unique IDs for each record.
The ID field is set to "identity" and has a unique constraint on it making
it a key field.

I create new records from an ACCESS 2000 front end. It was working fine
until yesterday when an operator shown me an error message to the effect ;
"tblxxx , attempt to insert duplicate key (or identity) values)..... error
xxxx".

The record would not be inserted. I went into SQL server (6.5) enterprise
manager and looked at the table indexes. I clicked "rebuild" and under
distribution "update".  After this new records would be inserted.

I  do not know why the problem occurs in the first place. I also do not know
why I was able to clear the problem by manually rebuilding the indexes. Do I
need to have a procedure to automatically check the indexes?

Any help would be appreciated. Thanks.

 
 
 

Attempt to insert duplicate identity values in table (has identity and key fields)

Post by Cyprian Liber » Fri, 10 Sep 1999 04:00:00


I have found out since this post that someone reset the machine on which the
sqlserver is located.  I have also found out that the problem can be
corrected by using,
DBCC CheckIdent (tablename, tablename2...)

after the server is restarted.


Quote:> I have set up my tables to have auto-generated unique IDs for each record.
> The ID field is set to "identity" and has a unique constraint on it making
> it a key field.

> I create new records from an ACCESS 2000 front end. It was working fine
> until yesterday when an operator shown me an error message to the effect ;
> "tblxxx , attempt to insert duplicate key (or identity) values)..... error
> xxxx".

> The record would not be inserted. I went into SQL server (6.5) enterprise
> manager and looked at the table indexes. I clicked "rebuild" and under
> distribution "update".  After this new records would be inserted.

> I  do not know why the problem occurs in the first place. I also do not
know
> why I was able to clear the problem by manually rebuilding the indexes. Do
I
> need to have a procedure to automatically check the indexes?

> Any help would be appreciated. Thanks.


 
 
 

Attempt to insert duplicate identity values in table (has identity and key fields)

Post by Charles Bretana Jr » Fri, 10 Sep 1999 04:00:00


Cyprian,

     On SQL 6.5, Unfortunately, there is a known issue with the Identity
Value not being kept up to date accurately when the server is shut down
without issuing a checkpoint... .During teh recovery process that runs when
teh server is restarted, Identity Values can be lost, causing teh next one
to be issued to be a duplicate.  This supposedly can only happen after a
Shutdown without a checkpoint, so I would c=investigate that possibility
first.  If so, running DBCC CheckIdent will correct the problem... If this
can and will happen regularly, you can protect yourself by implementing an
AutoStart Stored Proc that runs DBCC CheckIdent on every table during server
startup routines.....

Regards,

Charly


Quote:> I have set up my tables to have auto-generated unique IDs for each record.
> The ID field is set to "identity" and has a unique constraint on it making
> it a key field.

> I create new records from an ACCESS 2000 front end. It was working fine
> until yesterday when an operator shown me an error message to the effect ;
> "tblxxx , attempt to insert duplicate key (or identity) values)..... error
> xxxx".

> The record would not be inserted. I went into SQL server (6.5) enterprise
> manager and looked at the table indexes. I clicked "rebuild" and under
> distribution "update".  After this new records would be inserted.

> I  do not know why the problem occurs in the first place. I also do not
know
> why I was able to clear the problem by manually rebuilding the indexes. Do
I
> need to have a procedure to automatically check the indexes?

> Any help would be appreciated. Thanks.

 
 
 

1. Inserting select and a corresponding value from an identity field in another table

Novice SQL dude lookin for some help:

This trigger givews me the same value in my foriegn key field
I want it to increment.

CREATE TRIGGER msa_insert ON dbo.geo_msa
FOR INSERT
AS


/** to increment counter
insert into geo_mlist_id values(getdate())

/**to update field in new inserts

msa_id=inserted.msa_id
GO

******************************************

Should I use a cursor?

2. Multivalue Products - David Hochman????????

3. INSERT INTO TABLE KEYED ONLY ON IDENTITY COLUMN RESULTS IN KEY VIOLATION (6.5)

4. FM 4 (Mac) to FM 5.5 (Win)

5. SQL 6.5 Inserts duplicate identity value !?

6. SQL question (retriveing n number of rows)

7. Duplicate Keys with Identity Field

8. SQL ERROR

9. SQL 6.5 Inserts duplicate identity value !?

10. Merge Replication has duplicated IDENTITY field values!

11. Duplicate value in IDENTITY field

12. Duplicate Identity Field Values