LINQ with uncommon rows between two datatables

Hello Forum Members,

The following formula I found online provides uncommon rows from two datatables:

UnCommon Values

dt_UnCommonRows = dt1.AsEnumerable().Except(dt2.AsEnumerable(),System.Data.DataRowComparer.Default).CopyToDataTable

However, I want to show both rows. For example, perhaps the phone number is different in both rows, and I want to see both rows to compare the differences. How would the above formula be modified to provide those results?

Thank you


Could you maybe also try Switching the Datatables in the Expression and Check, dt1 becomes dt2 and dt2 becomes dt1


The formula that you are using will compare all the rows values and if any one does not match only then you get the values …

So if they are not matching then there would not be any corresponding rows for it…

If you match on some specific column then there can be a check on any other column if that is matching or not…

Eg: dt contains rows 1,2 and dt contains row 1.3 …these two are not matching…but if you take another row from dt1 say 3,4 …even those are not matching…

If you want unmatched from both tables with only comparing one column then we can modify the formula to match only that column


in Addition to above

have a look at the concept of data joins

your description from above sounds also like:

  • full join on some join columns
  • then post process the join result
1 Like

Thank you. It worked. And in hindsight, the answer was obvious, but still appreciated

1 Like

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