Merge Multiple Datatables

Hello,
I am struggling with an issue and hopefully someone can help me with here.

I have multiple datatables dt1, dt2, dt3, etc… they all have the same columns and headers. I want to merge all of them into one datatable dtX using maybe LINQ statement.

I ca do this with the merge activity but i’ll have to do it one by one. Is there a way to easily merge them together without having to use like 10 merge datatable activities? Thank you.

I haven’t played with merge data tables before but if you’re merging all 10 DTs into the same target, have you tried using a Collection to hold all the DTs and a for each construct to do the merge?

No i haven’t @pedro.arroyo how would that work

Hi @hatakora,
You would need to do the follwing:

  • Create a list of DataTable objects List<DataTable>
  • Add each dt to the collection (use Add to Collection activity)
  • Add a For Each activity (ForEach dt in dtList)
  • Add a Merge Data Table activity with this configuration:
    ** Destination: mergedDT
    ** Source: CType(dt,DataTable)

This will effectively merge all the data tables given that they all have the same schema.

Hi @hatakora

Use append range activity to append all datatable into single one

Make sense. I made an array and that seems to do it

Hi Nived,
How it is possible?
Any dummy workflow?

Check this Activities - Append Range

2 Likes

This thrown, “Object reference not set to an instance of an object” error.
Any idea, why i got this.

sorry. a silly mistake. Resolved :upside_down_face:

what was the solution i am facing same issue