Merge on 3 DataTables to one DT

Lets say i have a DT1 with just one column named ‘Name’, similarly with different records on DT2 with same column named ‘Name’ and DT3 as well. In short, i have 3 DT1 with different records but with one column named ‘Name’. I want those values consolidated in one DT (lets say DT4) with 3 different column names (like Name - DT1, Name - DT2, Name - DT3) and have associated records in each Column of it.

Name- DT1 | Name - DT2 | Name - DT3
Raja | Yihong | Bhai
Musk |Sekar| Aishwarya
Vijay | Sundar | Jason

Any suggestions?

Hi @Pradeep.Robot

You can use the following query in invoke code activity to achieve this:

Dim DT4 As New DataTable()
DT4.Columns.Add("Name - DT1")
DT4.Columns.Add("Name - DT2")
DT4.Columns.Add("Name - DT3")

DT4 = (From row In DT1.AsEnumerable()
       Select DT4.Rows.Add(row("Name").ToString(), "", "")).CopyToDataTable()

DT4.Merge((From row In DT2.AsEnumerable()
            Select DT4.Rows.Add("", row("Name").ToString(), "")).CopyToDataTable())

DT4.Merge((From row In DT3.AsEnumerable()
            Select DT4.Rows.Add("", "", row("Name").ToString())).CopyToDataTable())

Hope this helps,
Best Regards.

Thanks @arjunshenoy for your time - I dont have previlage to use invoke code activity within organization. Is there any other way this can be implemented?

Hi @Pradeep.Robot

Here is an example
ForumW (3).zip (11.4 KB)

Regards!