Compare two datatables

Hello friends,
@rkelchuri, @Ninett_Panfir, @Rammohan91, @balupad14, @Florent_Salendres, @vvaidya, @Palaniyappan,

I need to compare two datatables.
How to extract the rows of the second datatable which is not present in the first one, in order to process only the new rows of the new file.
Can you please share with me and example of xam?
Thank you,
Cami

1 Like

Kindly use join datatable activity @CamiCat
For more details with example

Cheers

1 Like

@CamiCat
You can use this method, If you want xml please let me know.

DataTable dataTable1; // Load with data
DataTable dataTable2; // Load with data (same schema)

// Fast check for row count equality.
if ( dataTable1.Rows.Count != dataTable2.Rows.Count) {
return true;
}

var differences =
dataTable1.AsEnumerable().Except(dataTable2.AsEnumerable(),
DataRowComparer.Default);

return differences.Any() ? differences.CopyToDataTable() : new DataTable();

3 Likes

any issues still @CamiCat

1 Like

Thank you so much @Sanjay3630.
I’ll try your kind solution and let you know as soon as possible.
Cami :slight_smile:

Hello @Sanjay3630

Do you have an xmal file for this? Appreciate it if you can share.

Thanks!

1 Like

@Englebert_Diongson

Please have the Xaml file for comparing tow tables
.Main.xaml (12.8 KB) Test_2.xlsx (9.7 KB)

Thanks

2 Likes

Hi @CamiCat
Here is a detailed article on that :slight_smile:

Regards,

THANK YOU. Was looking for a while for something better than for each row loop. Awesome