+ Start a Discussion
Sravanthi GSravanthi G 

if there is duplicate records in object?how to delete that duplicates with same name?

if there is duplicate records in object?how to delete that duplicates with same name?
Rahul KumarRahul Kumar (Salesforce Developers) 
Hi Sravanthi,

May I suggest you please refer the below link to delete duplicate records. Hope it helps.

Please mark it as best answer if the information is informative.so that question is removed from an unanswered question and appear as a proper solution.

Thanks
Rahul Kumar
Waqar Hussain SFWaqar Hussain SF
For deleting duplicate records assuming duplicate by name, You will have to first query all records then put names into a set to find duplicate reocrds and then delete the duplicate records.

Eg for deleting duplicate accounts
 
List<Account> Accounts = [Select ID, Name from Account];
set<string> DuplicateCheck = new set<string>();
set<Id> DupAccountIds = new set<Id>();
for(Account acc: Accounts){
	if(!DuplicateCheck.add(acc.Name))
	DupAccountIds.add(acc.Id);
}

delete [select Id from Account where Id IN :DupAccountIds];

 
Naveen DhanarajNaveen Dhanaraj
If you want to prevent from Entering Duplicate Records, you can use Standard Functionality Matching Rule and Duplicate Rule
 
These blogs will explain you step by step,
http://www.mstsolutions.com/blog/content/duplicate-management-salesforcecom
http://www.buanconsulting.com/duplicate-management-in-salesforce-com/
https://help.salesforce.com/articleView?id=managing_duplicates_overview.htm&type=0 (https://help.salesforce.com/articleView?id=managing_duplicates_overview.htm&type=0" target="_blank)
 

Matching Rule:https://help.salesforce.com/articleView?id=matching_rules_overview.htm&language=en_US&type=0
Duplicate Rule:https://help.salesforce.com/articleView?id=duplicate_rules_create.htm&language=en_US&release=206.5&type=0

If you have already Duplicate Records then by using This App filter it,
Try This Apps,
https://appexchange.salesforce.com/listingDetail?listingId=a0N300000058vzKEAQ
 https://appexchange.salesforce.com/listingDetail?listingId=a0N30000003IYLlEAO


Export The ID of the Duplicate Records and Delete it using Dataloader or workbench...

Insert, Update, or Delete Data Using Data Loader:
https://help.salesforce.com/articleView?id=inserting_updating_or_deleting_data.htm&type=0