Skip to main content
October 16, 2021
Question

Check duplicates in DB

  • October 16, 2021
  • 3 replies
  • 0 views

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
October 17, 2021

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
October 18, 2021

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.

May 11, 2023

how can i do it you explain clearly, via cdt