How to search the values from one data table into the another data table, if size of the data is huge

Hi @sambulkar ,

Could you let us know what is the Expected Output for the Inputs provided ?

Considering the DT1 has a column which contains values separated with comma. We can capture all values in that column as a list.

lotNos = DT1.AsEnumerable.SelectMany(Function(x)Split(x("Lot No").ToString,",").toarray).Select(Function(x)x).ToArray

Here, lotNos is a variable of Array of String and DT1 is your First Datatable where you have the Comma separated values.

Next, we can Filter the DT2 based on these lot numbers values captured.

DT2 = DT2.AsEnumerable.Where(Function(x)lotNos.Contains(x("Lot No").ToString)).CopyToDatatable

To Handle errors when Direct CopyToDatatable is used you could check the below post :

We have assumed you would need a filtered DT2 Datatable based on the Lot no values in DT1.

If the assumption is incorrect, then do provide us with the Expected Output, so we could analyse and suggest the appropriate solution.

1 Like