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
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
Cheers
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.
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.
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
Dt1
name, place
abc, efg
xyz, rst
DT2
ID, pin
123, 222
234, 456
Final Dt — expected
name, place, ID,pin
abc,efg,123,222
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
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
cheers
cheers
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
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()
).CopyToDataTable()
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.
Sequence.zip (2.5 KB)
Hope this will give some idea
Regards,
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.