I literally just implemented this exact same logic in a Robot on Tuesday. I did it with the “for each row” solution and IF Activities.
That said, I want to try something else, because I think it can be done via Invoke VB Code activity : Something like:
Array.ForEach(yourtable.Rows, Function(row) row(“Column50”) = row(“Column51”).ToString.Length > 0 ? row(“Column51”) : row("Column50))
Of course this is also iterating over the rows running the function on each row. If you have multiple “update” column pairs So column51 overwrites column50 if column51 has data, AND column53 overwrites column52 if column53 has data, then you modify the function to update both columns.
This will be more compact, but not really more efficient.
Even if we use LINQ to only select rows where Column51 has a value, and then iterate over them to perform the update, we would still be iterating over the table to select the rows, and then iterating over the results to perform the update. Still O(n) time complexity, so performance will be pretty much the same.
Bottom line is, I do not thing there is a better performing method to implement this. Unless your table is huge, all the methods should be pretty fast.
If your table is huge, it should be in SQL Server (or another database), and you use a SQL update statement.