Link to home
Start Free TrialLog in
Avatar of origfla
origfla

asked on

Fastest, Easiest, Most Efficient way to duplicate a Datatable column?

Hi Experts,

Quick question - Hopefully I don't know it, but what is the fastest way to duplicate a column in a datatable with all the data?

In other words, suppose I have a datatable with a column called "col1" populated with values. What I would like is to add a new column to my datatable called, say, col1_copy and have it have all the exact same values as col1.

I'm hoping there is a faster way than just:
Add column to Datatble with same structure as col1
Loop through datarows and copy from one column to the other
since my datatables are ENORMOUS and I'm duplicating quite a few columns and, so, updating the datatable value-by-value seems to be very slow...

PLEASE let me know the fastest, most efficient way to do this???

Thanks!!!
ASKER CERTIFIED SOLUTION
Avatar of Luis Pérez
Luis Pérez
Flag of Spain image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
If the above comment does not apply then I think looping and copying is the only option( I am not sure if LINQ can help here)