How do you create query that can be used to append data that has no unique ident

  • Thread starter Mitchell_Collen via AccessMonster.com
  • Start date
M

Mitchell_Collen via AccessMonster.com

How do you create query that can be used to append data that has no unique
identifier? I am afraid that if I append data twice on accident it will cause
duplicate data in the table. I tried selecting distinct but it doesn't work
and creating an auto number primary key will only generate an new number for
identical data. What should I do?

Thanks in advance! -Misty

INSERT INTO CURRENTINVOICES ( AH_ID, IV_BO, IV_PRICE, IV_DATE, IV_QTY, IV_SHP
)
SELECT INVOICES.AH_ID, INVOICES.IV_BO, INVOICES.IV_PRICE, INVOICES.IV_DATE,
INVOICES.IV_QTY, INVOICES.IV_SHP
FROM INVOICES;
 
K

Klatuu

You didn't say which field, so here is an example assuming AH_ID is the field
to match on. Now, I am not sure the parens are all correct, you may have to
debug it a bit.
INSERT INTO CURRENTINVOICES ( AH_ID, IV_BO, IV_PRICE, IV_DATE, IV_QTY,
IV_SHP) SELECT INVOICES.AH_ID, INVOICES.IV_BO, INVOICES.IV_PRICE,
INVOICES.IV_DATE, INVOICES.IV_QTY, INVOICES.IV_SHP FROM INVOICES
WHERE [AH_ID] In (SELECT [AH_ID] FROM [INVOICES] As Tmp GROUP BY [AH_ID]
HAVING Count(*) = 0 )
ORDER BY [AH_ID];
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top