azure-sql-databaseazure-logic-apps

Azure Logic Apps: Set condition to False when SQL query returns no rows of data


How can i conditionally test the output from an Execute SQL Query to make sure it returns some rows of data.

In my example below if the query returns no rows I don't want it to send an email, I want to do something else. What is the test?

What do i put here

Thanks for your time


Solution

  • I test, if it queries result is no rows, the query body will be like this:

    {
      "OutputParameters": {},
      "ResultSets": {}
    }
    

    So you could add a Condition with @{body('Execute_a_SQL_query')['OutputParameters']} is equal to {}. If true, do the things you want. Yo could set this in the Code view mode.

    enter image description here

    The below is the test result, hope this is what you want.

    enter image description here