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.

9 REPLIES 9

Neeraj Sharma10
Tera Guru

Hi Nitesh Alashe

 

 

 

 

 

You can use background script to delete multiple records.
just have to built logic to find duplicates.

 

you will find   the below links helpful

 

 

 

Useful User Scripts - ServiceNow Wiki

 

Delete multiple records using background scripts

 

 

 

Thanks

 

Neeraj Sharma

 

Community Alums
Not applicable

Hi Ankur,

Your Script is working completely fine and does the job.

 

Thanks for sharing!

 

Sai Krishna

@Ankur Bawiskar 

 

I have a similar requirement on the variable table (item _option_new) , here my script is generating duplicate variables with the same backend name i.e. field "name". I want to delete those duplicate variables. But catch here is , these variables are for respective catalog items, so duplicate variables should be removed from each catalog item. i.e. that respective variable should be present only once in each catalog item.

 

So, the requirement is , i need to remove duplicate variables from the catalog item. But the same variable with the same name can exists in another catalog item.

 

Exampple

 

SachinGavhane_0-1671511053787.png

 

here , in the catalog item "change lease" the variable page_general_1 is repeated twice is duplicated and i want to remove those duplicates from this catalog item but that variable may exisits in someother catalog item.

 

Please help

 

antin_s
ServiceNow Employee
ServiceNow Employee

Hi Nitesh,



I don't think deleting 100 records is a big deal and you don't want to write a script for it.



Go to https://instancename.service-now.com/sys_choice_list.do   (replace instance name with your instance name), sort by created by, apply the required filters, and select the records you want to delete using the check boxes on the left and delete.




find_real_file.png



Hope this helps. Mark the answer as correct/helpful based on impact.



Thanks


Antin