How to append two data tables with out merge activity

Hi all,

how to add to to data table, number of columns is same but some columns are different but still need to add the data

for ex table1

image

table 2

image

Plese let me know how to these two table.

I used to merge activity, due to different column names its not working so please let me know another way.

Hi @vineelag ,
You can join data table
regards,
LNV

1 Like

You can use the join data table activity or else

you can use this lina query to join tables
(From a In Dt1.AsEnumerable()
Join b In Dt2.AsEnumerable()
On a(“name”).ToString Equals b(“name”).ToString
Select Dt3.LoadDataRow (New Object() {
a.Field(Of String)(“name”),
a.Field(Of String)(“class”),
a.Field(Of String)(“City”),
b. Field(Of String)(“name”),
b. Field(Of String)(“age”),
b. Field(Of String)(“city”)

},False)).CopyToDataTable

1 Like

hi @vineelag

can you share the excepted output which you want

i tried using join datatable activity it does not work for me.

Based on your output image, we can try once more.

1 Like

Hi @Shiva_Nikhil

image

Expected output

Hey! can u try using append range activty @vineelag

image

3 Likes

Hey @Shiva_Nikhil ,

You can try using ‘For each row’ for your input file and the ‘add to datarow’ to the output file

image

1 Like

hi @vineelag

i am sharing the zip file can you look into it

append datatable.zip (8.7 KB)

Hope this helps

1 Like

Hey @vineelag ,

Try below method
image

Hope it helps you out!

1 Like

Please try this,

(From d In dt2.AsEnumerable
Select r = dt1.Rows.Add(d.ItemArray)).CopyToDataTable

image

Its working for me, note that combined output will be in dt1

1 Like

you can try this way

and output

image

Cheers @vineelag

1 Like

you can try with LINQ query also
assign activity- you can pass like this

dt1 = dt1.AsEnumerable().Union(dt2.AsEnumerable(), DataRowComparer.Default).CopyToDataTable()

so the out put in dt1

you can try both ways it may help you !

cheers …! @vineelag

1 Like

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