Compare two data table and write it Excel sheet

Hi All,

I have two data table headers is common 1st is like data base
2nd data table is success report.

Need to compare two data table and update the values which ever we have in success report column in to database if the values of code is present

Please look the pictures,

If you give solution in LINQ which is awesome

Hi @Vicky_K

Please give the following query a try. In the Assign activity:

dt3 = (From row1 In dt1.AsEnumerable()
       Join row2 In dt2.AsEnumerable() On row1("Code").ToString() Equals row2("Code").ToString() Into grp = Group
       From g In grp.DefaultIfEmpty()
       Let status = If(g Is Nothing, "", g("Status").ToString())
       Select dt1.Rows.Add(row1("Sl No"), row1("Code"), row1("PD_D1"), g("PD_D2"), status)).CopyToDataTable()

Hope this helps,
Best Regards.

Hi @Vicky_K

Can you try this-

(From row1 In dtDataBase.AsEnumerable()
Join row2 In dtSuccessReport.AsEnumerable()
On row1(“Code”).ToString() Equals row2(“Code”).ToString()
Select dtDataBase.Rows.IndexOf(row1), row2(“Value”)).ToList().ForEach(Sub(x) dtDataBase.Rows(x.Item1)(“Value”) = x.Item2)