Join tables

I have 2 datatables dt_allRecords and dt_todayRecords.

The intension is to create a dt_newRecords datatable where I get values from dt_todayRecords which is not present in dt_allRecords.

I’ve tried Left join in Join Tables activity but not getting expected results. I think I have to implement left outer join.

Please advise.
Thanks

@shrishti.diggikar

It is a combination of join and filter

  1. Join on left
  2. Then filter the values of any one column which you feel is a unique value column with empty records…so records which are not matched will only be present as those records will be empty on the all records table related columns

Cheers

Hi @shrishti.diggikar

Can you share sample input for both data tables.

Regards

Hey @shrishti.diggikar , try using the following LINQ

(From row1 In dt_todayRecords
 Where Not dt_allRecords.AsEnumerable.Any(Function(row2) 
 Enumerable.SequenceEqual(row2.ItemArray, row1.ItemArray))
 Select row1)

Enumerable.SequenceEqual checks if two sequences, like arrays or lists, contain the same elements in the same order and the output is a boolean value. If the values are equal, it gives true, and if it doesn’t, it gives false.

2 Likes

Hi @shrishti.diggikar ,

We could also try with the Except method provided that the Schema of the two tables are the same :

dt_newRecords = dt_todayRecords.AsEnumerable.Except(dt_allRecords.AsEnumerable,DataRowComparer.Default).CopyToDataTable

The Direct CopyToDatatable gives out error if there are no filtered rows found, hence we could follow the below method to handle it :

1 Like

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