You haven’t specified which BDS you’re using. However, here is an alternative to SQL Server that is often faster than the answers that have already been posted.
MERGE tabelaA AS Target
USING (SELECT column1, column2, someInt, someVarChar FROM tabelaB) AS Source
ON (Target.column1 = Source.column1 AND Target.column2 = Source.column2 AND (...))
WHEN NOT MATCHED BY TARGET THEN
INSERT (column1, column2, someInt, someVarChar)
VALUES (Source.column1, Source.column2, Source.someInt, Source.someVarChar)
This form is also more flexible if, in the future, you decide that you need to, for example, update the records in the target table if they already exist. This can be done as follows:
MERGE tabelaA AS Target
USING (SELECT column1, column2, someInt, someVarChar FROM tabelaB) AS Source
ON (Target.column1 = Source.column1 AND Target.column2 = Source.column2 AND (...))
WHEN NOT MATCHED BY TARGET THEN
INSERT (column1, column2, someInt, someVarChar)
VALUES (Source.column1, Source.column2, Source.someInt, Source.someVarChar)
WHEN MATCHED THEN
UPDATE SET Target.column1= Source.column1
Maybe a
WHERE NOT EXISTS Xyz
?– Rafael Withoeft
@Rafaelwithoeft Would you kindly demonstrate how the structure would look?
– Rafael Barbosa
I found an example for you, I hope it helps: http://stackoverflow.com/questions/3164505/mysql-insert-record-if-not-exists-in-table
– Rafael Withoeft