I just archived and deleted a bunch of records and there was a very important piece of my code commented out that caused me to delete too many records. Fortunately I archived them, but I'm trying to insert them back into the table, but I get this message:
Violation of PRIMARY KEY constraint 'PK__gmcmpany__1CBC4616'. Cannot insert duplicate key in object 'tablename'.
Here's the SQL statement that I'm using for the insert - note that I'm verifying that the records don't exist in that table:
INSERT INTO tbldeletedfrom (field list)
select (values)
from tablea a, archivetable b
where a.id = b.id and not exists
(select c.id from tbldeletedfrom c where c.id = b.id)
What might be going on? I need help asap. Thanks!
Violation of PRIMARY KEY constraint 'PK__gmcmpany__1CBC4616'. Cannot insert duplicate key in object 'tablename'.
Here's the SQL statement that I'm using for the insert - note that I'm verifying that the records don't exist in that table:
INSERT INTO tbldeletedfrom (field list)
select (values)
from tablea a, archivetable b
where a.id = b.id and not exists
(select c.id from tbldeletedfrom c where c.id = b.id)
What might be going on? I need help asap. Thanks!