I have the following SQL Query:
INSERT INTO Archive_E2LTORI SELECT * FROM E2LTORI WHERE LGNUM = '" & prRS("LGNUM") & "' AND TANUM = '" & prRS("TANUM") & "' AND VBELN ='" & Delivery & "' AND VBELN NOT IN(SELECT VBELN from Archive_E2LTORI where VBELN= '" & Delivery & "'
It basically copys data from the LIVE table to the arichive table.
The problem is that I kept getting a a primary key issue - so I then added the "NOT IN" so that the query makes sure that the combo exists before inserting.
My question is:
Is this correct? Or should I add the addtional fields the the NOT IN part?