Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Automate - General Discussion
Unanswered

Access output from Execute a SQL Query (V2)

Like (0) ShareShare
ReportReport
Posted on 13 Jul 2021 01:59:39 by 101

I'm aware this question has been asked several times, but it seems the functionality of this item has changed recently and none of the solutions people have suggested are working for me.

 

I have a Flow which is triggered through PowerApps, taking several input parameters (provided by PowerApps) to verify whether 1 or more records matching the parameters already exist in a SQL table.

 

Execute a SQL query (V2) action:

alex93jansen_3-1626141165925.png

Execute a SQL query (V2) response:

alex93jansen_2-1626141081439.png

The issue is that there's no way for me to access the "count" variable in this response. I have tried the "Compose" and "Parse JSON" actions, but neither allow me to input the SQL response body anywhere.

 

 

  • eric-cheng Profile Picture
    5,171 on 13 Jul 2021 at 18:30:54
    Re: Access output from Execute a SQL Query (V2)

    Glad its sorted

     

    --------------------------------------------------------------------------
    If I have answered your question, please mark my post as a solution
    If you have found my response helpful, please give it a thumbs up

  • alex93jansen Profile Picture
    101 on 13 Jul 2021 at 17:46:12
    Re: Access output from Execute a SQL Query (V2)

    Thanks for the reply.

     

    I tried Option 1, as follows:

    alex93jansen_0-1626197287352.png

    which creates the "Schema" in the Parse JSON action. However, for the "Content" I'm not able to put any Dynamic Content from the SQL query action (only PowerApps items show up):

    alex93jansen_1-1626197369107.png

     

    I also tried Option 2 which does work, so I got everything work the way it should now. Thanks.

  • eric-cheng Profile Picture
    5,171 on 13 Jul 2021 at 06:07:27
    Re: Access output from Execute a SQL Query (V2)

    Hi @alex93jansen ,

     

    Because Table1 is a JSON array, it will try to loop the JSON objects within. 

     

    I will provide two options:

     

    Option 1 

     

    ericcheng_1-1626155978703.png

    Add a Parse JSON underneath and copy the above Body into the sample JSON payload

    ericcheng_2-1626156279825.png

     

    Add a Compose action underneath and go to expressions and paste this in (you may need to tweak Parse_JSON depending on the name of the action in the previous step).  What this does is to return the first JSON object in the index and count field.

     

    body('Parse_JSON')?['ResultSets']?['Table1'][0]['count']
     

    ericcheng_3-1626156294637.png

     

    When you run it, it should return the count

    ericcheng_4-1626156429369.png

     

    Option 2 

     

    You could also try the Get rows (v2) action which will still allow you to apply filters.  You can then get the length of the value to get the row count.

     

    length(body('Get_rows_(V2)')?['value'])
     
    ericcheng_0-1626155573095.png

     

    --------------------------------------------------------------------------
    If I have answered your question, please mark my post as a solution
    If you have found my response helpful, please give it a thumbs up

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Congratulations to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Power Automate - General Discussion

#1
ankit_singhal Profile Picture

ankit_singhal 5 Super User 2025 Season 1

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 4 Super User 2025 Season 1

#3
David_MA Profile Picture

David_MA 2 Super User 2025 Season 1

Overall leaderboard
Loading started