Adding column data from one datatable to another

Hi all,

Need help for the below scenario.

i have 2 datatables which are having different columns but i want to add the column from 2nd dt to 1st dt. but not having any common data.(append)

any possibilities?
using LINQ query

Thanks in Advance


If number of rows are same…then you can try using add data column activity and pass the column as dt1.Columns(“Columnname”)

Please try and let us know


1 Like

Hi @Anil_G ,

Can you please elaborate.


That would add the column “next to” the existing column. Megha wants the data appended.


Rename the column in the second datatable so it matches the first datatable, then use the Merge Datatable activity to combine them into one datatable.

1 Like

Hi @postwick ,

I tried but not working for me.

There are 2 datatables, the column data are completly different in 2 datatables and also it amy exceed 50000 rows, I want to append the columns from dt2 to dt1 as the last columns where no common columns or data present.

Can you please help on this using linq query.

Thanks in Advance.

Then don’t rename the column, but still use Merge Datatable.

@postwick ,

i tried merge datatable but the data from 2nd column is adding after the rows of 1st datatable.
i want to add in the same rows of dt1.

for ex

1st row dt2 row should be added to dt1 row like this


name, place
abc, efg
xyz, rst


ID, pin
123, 222
234, 456

Final Dt — expected
name, place, ID,pin
xyz, rst,234,456

Then use Add Data Column. Provide dt2.Columns(“ID”) as the column to add to dt1. Then another Add Data Column and provide dt2.Columns(“pin”) as the column to add.

Hi @meghana1929

Then follow the steps

  1. First add the required columns to first datatable say dt1
  2. Use for each row in datatable activity and in the properties add a variable for index
  3. Use assign activity with currentrow(“ColumnName”) = dt2.Rows(index)(“ColumnNmae”).ToString

Repeat step 3 for each column you want to add

at the end of loop dt1 will have all the data from dt2 appended beside the data already present in dt1



Hi @meghana1929 ,

Check this workflow attached below and I have used the above data which you mentioned,
Uipath_AddingDataToOtherTable.xaml (11.3 KB)

Hope this might help you :slight_smile:


Hi @meghana1929

Assign dt1 = ... //first DataTable
Assign dt2 = ... //second DataTable

//Add a new DataColumn to dt1 with the same name as the column in dt2 that you want to append
dt1.Columns.Add(dt2.Columns("ColumnName").ColumnName, dt2.Columns("ColumnName").DataType)

//Use LINQ to generate a new DataTable with the values from dt1 and the new column from dt2
Assign dt3 = (From row1 In dt1.AsEnumerable()
              From row2 In dt2.AsEnumerable()
              Select row1.ItemArray.Concat({row2("ColumnName")}).ToArray()

In this example, replace “ColumnName” with the name of the column in dt2 that you want to append to dt1. The new column will have the same name and data type as the column in dt2.

Hii @meghana1929 ,
you can refer this one. (2.5 KB)

Hope this will give some idea

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