Showing results for 
Search instead for 
Did you mean: 
Kudo Kingpin
Kudo Kingpin

Compare records from 2 SQL Tables


I have 2 identical SQL tables and a flow that copies all records that are older than 7 days from Table 1 to Table 2 and then delete from Table 1. 

But the flow fails to run frequently while trying to copy duplicate records from Table 1 to Table 2. (Table 2 doesn't accept duplicate records for a certain column.)

So I'm planning to add a condition to check if a certain record exists in Table 2 before copying and skip those records if the condition is true.

Below is a screenshot from my flow. Much appreciated if someone can show some light to achieve this. Thanks!



Community Support
Community Support

Hi afernando,


I am trying to find a way to check if a certain record from table1 exists in table2 before copying.

I consider to get rows from the two tables, then add a condition to check if there are same records. But when configuring the condition, I got the error message saying that “This output is an array. A foreach cannot be nested inside of another foreach.” So I was failed with it.

I am still trying to find other available ways to achieve this.

Best regards,
Mabel Mao

Community Support Team _ Mabel Mao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi @v-yamao-msft,


Thanks for trying. I'm just wondering if flow supports error handling. If so I can set the flow with a condition to skip rows with errors. 

Any ideas?




Regular Visitor

I am also interested to know if it is possible to compare records from 2 different SQL tables.


Wonder if anyone has a solution?

Helpful resources

Process Advisor

Introducing Process Advisor

Check out the new Process Advisor community forum board!

MPA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

Users online (10,170)