Compare two datatables and get mismatched records

I want to compare two datatables, get the mismatched records using LINQ query. Please help me

Check this post: How to see which item is different when comparing two datatables

@qbss Mismatched records from 1 datatable or both Datatables ?

Try this,
Get rows that exists in dtTable1 but not in dtTable2
dtDifference= dtTable1.AsEnumerable().Except(dtTable2.AsEnumerable, DataRowComparer.Default).CopyToDataTable

Get rows that exists in dtTable2 but not in dtTable1
dtDifference= dtTable2.AsEnumerable().Except(dtTable1.AsEnumerable, DataRowComparer.Default).CopyToDataTable

Hope this helps. Let me know if it doesn’t.

1 Like

one data table

@qbss Query Provided by @Madhavi Should Work, if it doesn’t then you need to provide more information :sweat_smile:

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