Skip to main content
Participating Frequently
Oct 16, 2021 6:04 PM UTC
Question

Check duplicates in DB

Hi All,

I have a table Emp_personal_details and i have around 200 records in that table.

Now I need to Insert around 400 new records into the same table. But the new records have some duplicates which are already in the DB.

How can I write a sql script to check duplicates in the table and insert the remaining records into the Appian DB.

Thanks

3 replies

selvakumark
Participating Frequently
Oct 17, 2021 1:20 PM UTC

Hi Harika,

This can be easily done with the help of a temporary table in the database level. Below are some useful links:
https://stackoverflow.com/questions/43864144/sql-avoid-duplicate-being-inserted-into-staging-temp-table
codingsight.com/.../

csteward
Brainy
Oct 18, 2021 2:59 PM UTC

Additionally, if you are using an INSERT in SQL, you can skip rows that are already present by utilizing WHERE NOT EXISTS (Select *..)..

Or if you are loading records in via Appian CDT with all 400 in it, you can iterate through a rule that checks the DB with a!queryEntity(), and retrieve the IDs for those existing rows into the CDT, which would result in an UPDATE (no change) on those and an INSERT for the new rows.

Known Participant
May 11, 2023 6:50 PM UTC

how can i do it you explain clearly, via cdt