Join 3 Datatable into 1

Hello Everyone,

I have 3 Datatable with same number of columns and same column name, I want to join all 3 into 1 how to do with linq, anyone pls suggest

Hi @Manii_K

resultDataTable = (From row In DT1.AsEnumerable()
                                    Select row).Union(
                                   From row In DT2.AsEnumerable()
                                   Select row).Union(
                                   From row In DT3.AsEnumerable()
                                   Select row).CopyToDataTable()

Regards,

@Manii_K

Another way

resultDataTable = (DT1.AsEnumerable().Concat(DT2.AsEnumerable()).Concat(DT3.AsEnumerable())).CopyToDataTable()

Regards,

is it about merging?
Assign Activity
dtMerged =

{dt1,dt2,dt3}.SelectMany(Function (x) x.AsEnumerable).CopyToDataTable

Or is it about Data Joins joining?

@Manii_K,

Better to use Merge Datatable activity here. Give it a try.

Thanks,
Ashok :slightly_smiling_face:

If they have the same columns, then it sounds like you want to do a merge, not a join. Use the Merge Data Table activity.

@lrtetala It’s working thanks

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