Linq query to merge datatable

Hi @ppr

I have one issue on merging the data table. Please help to fix it.

I have uneven row of data in the data table. Just i want to merge the data on right of one data table value to another data table

Dt1 have 1 on row of data
Dt2 having more than 3 row of data
Dt3 having more than 4 row of data
Dt4 having 2 row of data
Sometime any one or two data table has empty.


Hi @Shyam_Pragash ,

Check this below example workflow attached to merge datatables,
Uipath_MergeDataTable.xaml (13.6 KB)

Hope this might help you :slight_smile:

Hi @Manish540

Thanks :slight_smile:

As per your xaml file merge the data table in the bottom of one to another datatable. But i need all the data table are joined or merged in the right side of one to another datatable (with header or without header)

Expected Output:



Hi @Shyam_Pragash

Try the below
(From dt1 In dataTable1.AsEnumerable()
Join dt2 In dataTable2.AsEnumerable()
On dt1(“ID”) Equals dt2(“ID”)
Select dt1.ItemArray.Concat(dt2.ItemArray).ToArray()).CopyToDataTable

Hi @V_Vasanth_Kumar

All the datatable values are not equal.

i tired as you mension code.


Hii @Shyam_Pragash ,
Please check this workflow. (3.3 KB)

Hope this might help you :slightly_smiling_face:

1 Like

Hi @Shyam_Pragash,

“Build Data Table” activity creates an empty datatable with three columns: “Column1”, “Column2”, and “Column3”. The “Assign” activity populates Dt1 with a single row of data, and Dt2, Dt3, and Dt4 with multiple rows of data.

The “For Each” loop iterates through each datatable and merges the data into the empty datatable. The “If” condition checks if the datatable is empty, and if it is, skips the merge. The “Merge Data Table” activity merges the datatable into the empty datatable using a “Right” join type to preserve the rows in the datatable being merged.

After the loop completes, the “Output Data Table” activity displays the merged datatable.

I hope this helps!