Add column to data table from other data table


#1

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.


#2

Hi Yuvaraja,

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


#3

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.


#4

Refer this @yuvaraja


#5

Thanks @sreekanth will refer this.


#7

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


#8

Hey @yuvaraja

Sorry …My bad…

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

Regards…!!
Aksh


#9

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


#10

Thanks @aksh1yadav , this method works well.


#11

Thanks @heynow will check this method as well.