Add column to data table from other data table

HI All,

I have a datatable A with one column ‘Incident Id’ and other datatable B with status , how can i add both columns into a single data table. Pls suggest.

Hi Yuvaraja,

By using write range activity, you can merge them into a single data table.

Thanks Lakshman, But I guess with this we can write only into excel and again we have to read it to get those into single data table. It would be nice if I can able to do this without reading/writing from excel.

Refer this @yuvaraja

Thanks @sreekanth will refer this.

HI @aksh1yadav i tried this already but this is giving data like this only, it adds up the values in one column alone,

Incident_id,Status
1,
2,
,open
,completed

Hey @yuvaraja

Sorry …My bad…

Check it out the attached sample - Datatable Merge WIth Different Schema.xaml (14.7 KB)

Regards…!!
Aksh

1 Like

I like invoke code, here is simple solution.

Dim i As Int32
dt1.Columns.Add(dt2.Columns(columnName).ColumnName,dt2.Columns(columnName).DataType)
For i=0 To dt1.Rows.Count-1
dt1.Rows(i).Item(columnName) = dt2.Rows(i).Item(columnName)
Next i

Thanks @aksh1yadav , this method works well.

Thanks @heynow will check this method as well.