I Want to Delete Duplicate Records from Table
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-05-2017 02:25 AM
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.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago - last edited 3 weeks ago
Option 1 : Use the Import Set to delete only the 2nd load
If you used Load Data / Import Set, the cleanest approach is:
Go to System Import Sets > Import Sets
Open the Import Set record for the second load (100 records)
In related lists, open Import Set Rows
Identify a field/value that marks those rows as “second file” (often import set sys_id)
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:
Filter sys_choice by Created on range for the second import
Validate count = 100
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
