A very fast problem occurs. In an int auto-increment table, the primary key field is not involved when information is inserted. the following error occurs: violation of primary key constraint 'pk _****'. cannot insert duplicate key in object 'dbo. tablename '. duplicate keys cannot be inserted in the table!
The same error is reported when the statement is directly executed in the query analyzer.
Solution:
1. Cancel the primary key and then set the primary key,ProgramRun as usual
2. Execute the following SQL statement, copy the result, and run
Select 'dbcc checkident ('+ table_name +') 'from information_schema.tables where table_type = 'base table'
Cause: the seed value is not synchronized with the actual value in the Table. the DBCC checkident statement is used to check if the current ID value of the table is smaller than the maximum id value stored in the column, use the maximum value in the ID column
Line reset ~!