+ Start a Discussion
jhurffjhurff 

Is It Possible To Identify Duplicate Records Via SOQL or API?

Hi All...

 

Please excuse me as I am new to the SF developer community.

 

I am looking for a method to programatically identify potential duplicate contact records within the SF database.  We are going through a cleansing activity against our SF database and I'd like to be able to run an ad hoc query to identify duplicates.  In general, I am looking for the ability to run GROUP BY queries against the database.  I don't see this as a capability within the SOQL documentation.  Is there a way to issue a statement something like the following...

 

select q1.FIRSTNAME, q1.LASTNAME
from CONTACTS q1
where 1 < (select count(*)
from CONTACTS q2
where q1.FIRSTNAME = q2.FIRSTNAME AND q1.LASTNAME = q2.LASTNAME)

 

 Or something similar?  I basically need to identify contacts with the same first and lastname to identify if they are really dupes.

 

Any suggestions would be greatly appreciated.

John De SantiagoJohn De Santiago
There isn't a way to do a group by type query or a query like the example you gave using SOQL to identify duplicates. What I have done in the past is export all of the contacts using the data loader and import the generated CSV file into Access or SQL Server Express. I then run the group by queries that I am used to running and identify the duplicates. Once I have the list of duplicates I can choose to flag them in the system as duplicates or to delete them using the data loader. 
ajaslkfjqpr89q0ajaslkfjqpr89q0

With Winter 2010 there are some new features functions available in SOQL including Group By. See below:

 

 

http://www.ext-it.com/2010/blog/soql-group-by-grouping-records-in-salesforce-com.html