Copy duplicated rows of a datatable into another datatable

Dear everyone,

I need help here.
I have everyday around 5000 rows of which I need to identity the duplicated row based on the value of a specific column, say “column 1”. I tried the following expression and it works for small datatable:

duplicatedDT = dt.AsEnumerable.Where(function(y) dt.AsEnumerable.Count(function(x) x(“Column 1”).toString=y(“Column 1”).toString)>1).CopyToDataTable()

but when I apply it to the real datatable, the script stucked for more than 10 minutes until I had to stopped it.
Do you guys have the better expression for this?
Appreciate your help.

Cheers!

@Nazarius
find some starter help here:
FindDupsUniquesFirstFromGroup_By1Col.xaml (8.0 KB)

In case of empty search results a re to expect, then save it up before like:

hi ppr,

By applying your method i got the following error message: “The source contains no DataRows.”
I just simply changing the datatable name to my dt and also the column number to the column name of the respective column. Do you know the reason for this problem?

Thank you.

Give a try in incorporating the Handling of empty results and described above and Check IT again

The datatype of the drDuplicatesOnly variable is list(of datarow)

Also please correct from dtdata to dtdata.asenumerable

1 Like

Ok,

I will try and get back to you.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.