How to concatenate two columns in datatable without looping and keep concatinated data in new column?

This is the my case:

Name Account
AA 123
BB 345
CC 654

Output should like this:
Name Account Formula
AA 123 AA123
BB 345 BB345
CC 654 CC654

This should done without loops


Hi, From where this datatable is populated, there itself you can try to populate the third column as well. Sorry if my understanding is not correct here. Let us know where you are getting the datatable dt1.

DB or from Excel

If it is from DB then we can achieve this using query in the database itself.
If it is from Excel, then append the excel before reading it for the third column then read it.

Don’t go for excel or DB , I want this manipulation on DataTable only.


Check this link, they tried the similar stuff only.

The expected result is single column table with same three rows but two column merged into single column like (A1-b1, a2-b2, a3-b3)

Here is the solution:
Use Invoke method activity, assume my DT column names are ‘Entity’ and ‘AccountId’.
TargetObject: DT.Columns.Add(“FORMULA”, GetType(String), “[Entity]+[AccountId]”)
MethodName: SetOrdinal (Need to pass the ordinal value using argument)

Where FORMULA- my new column name(Concatenated columns)
SetOrdinal- new column ordinal position


Hi @VasuNaidu Thank you so much for taking the time sharing your solution. I was able to implement this.
P.S. Sorry I deleted my previous entry because I implemented it with a loop, but Invoke Method was so much better(performance wise).

Hi vasu…your solution worked if I build a data table set a variable and pass it…but if I read from excel store it in a data table and pass that…the columns are getting added …for example columnA:12001 columnB:1 my desired output is column C:120011 but IAM getting columnC:12002…please help…

1 Like