cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
BrianH
Microsoft
Microsoft

How to handle no records returned from Execute a SQL Query (V2)?

My flow runs a query to get records from the database using Execute a SQL Query (V2). Then is enters into Apply to each loop. But sometimes the query will return no results (which is expected). I am currently getting the error below. How to I not go into the Apply to each loop if there are no records returned from the query?

 

The execution of template action 'Apply_to_each_2' failed: the result of the evaluation of 'foreach' expression '@body('Execute_a_SQL_query_(V2)')?['resultsets']?['Table1']' is of type 'Null'. The result must be a valid array.

1 ACCEPTED SOLUTION

Accepted Solutions
BrianH
Microsoft
Microsoft

I have found a workaround. I am checking if the table object is null using a "Condition"

 

 

Screenshot 2021-03-26 135235.jpg

View solution in original post

1 REPLY 1
BrianH
Microsoft
Microsoft

I have found a workaround. I am checking if the table object is null using a "Condition"

 

 

Screenshot 2021-03-26 135235.jpg

View solution in original post

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Users online (2,279)