How to Get Similar Values from two different Datatables

Hello All,

I have two Data tables and few columns are similar in two datatables.I want to check a value from DT1 is present in DT2 if yes then it DT2 result data row should be copied to different Data table DT3 without using loop. Please anyone let me know how can we achieve this without using loop

It would be helpful if we could rely on some sample data

In general, we can do it (one of many options with LINQ). It is a match case

Assign Activity
dt3 =

(From d in dt2.AsEnumerable()
Let cv = d(ColNameOrIndex).ToString.Trim
Let chk = dt1.AsEnumerable.Any(function (d1) d1(ColNameOrIndex).ToString.Trim.Equals(cv))
Where chk
Select r = d).CopyToDataTable

Handling empty results:

:ambulance: :sos: [FirstAid] Handling of The source contains no DataRows exception - News / Tutorials - UiPath Community Forum

Hi @Aswini

Try this query

dt3= (From row1 In dt1.AsEnumerable()
                        Join row2 In dt2.AsEnumerable() On row1.Field(Of String)("CommonColumn") Equals row2.Field(Of String)("CommonColumn")
                        Select row2).CopyToDataTable()

Hope it helps

This is called a join, a standard database operation. Use the Join Data Table activity.