I Want to Delete Duplicate Records from Table

Nitesh A
Tera Expert

Using load data, i had loaded 800 records in my sys_choice table.

Again i had loaded the file having 100 records.

But that 100 records already inserted during import of 800 records.

so know i have total 900 records in which 100 are duplicate records.

and i want to delete those 100 duplicate records.

please anyone having solution for this.

10 REPLIES 10

Nayan ArchX
Giga Guru

Option 1 : Use the Import Set to delete only the 2nd load

If you used Load Data / Import Set, the cleanest approach is:

  1. Go to System Import Sets > Import Sets

  2. Open the Import Set record for the second load (100 records)

  3. In related lists, open Import Set Rows

  4. Identify a field/value that marks those rows as “second file” (often import set sys_id)

  5. Now delete from sys_choice only those inserted by that import:

    • If you mapped in a field like u_source_import_set or u_batch_id → filter by it and delete.

    • If not mapped → see Option 2/3.

Best when you tracked source/batch.

 

Option 2 : Use sys_import_set_row tracking (if available)

Sometimes you can identify the duplicate 100 by:

  • sys_created_on time window of the second load

  • sys_created_by (your user)

  • exact file name / import set

Then:

  1. Filter sys_choice by Created on range for the second import

  2. Validate count = 100

  3. Delete those 100

This works if the second import happened in a clear time window.

 

Best practice so this never happens again

For sys_choice, don’t blindly insert. In your transform map:

  • Use Coalesce on the uniqueness fields (name, element, value, language, etc.)

  • This makes imports update existing instead of creating duplicates.

 

If my response has resolved your query, please consider giving it a thumbs up ‌‌ and marking it as the correct answer‌‌!

 

Thanks

Nayan Patel

IT ServiceNow Consult, ServiceNow ArchX

If my response has resolved your query, please mark it Helpful by giving it a thumbs up and Accept the Solution