web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / I want the flow to sto...
Power Automate
Answered

I want the flow to stop if the sql query returns 0 rows

(0) ShareShare
ReportReport
Posted on by 75

I want the flow to display message that item "abc" not found when we try and filter a excel sheet using sql query, and also stop the flow

  • Verified answer
    CU16071609-1 Profile Picture
    6,255 Moderator on at

    @bensat2 

     

    Please follow the below approach.

    Deenuji_1-1711990838813.png

     

    Code:

    SET StrConnect TO $'''Connect'''
    SET Create TO $'''sdds'''
    Database.Connect ConnectionString: $'''Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=Fruits;Data Source=DESKTOP\\SQLEXPRESS''' Connection=> SQLConnection
    @@copilotGeneratedAction: 'False'
    Database.ExecuteSqlStatement.Execute Connection: SQLConnection Statement: $'''SELECT [Pub]
     ,[date]
     ,[pm]
     FROM [Fruits].[dbo].[Stocks]
     where (Pub= \'%Create%\')''' Timeout: 30 Result=> QueryResult
    IF QueryResult.RowsCount <= 0 THEN
     EXIT Code: 0
    END
    Display.ShowMessageDialog.ShowMessage Title: $'''test''' Message: $'''test''' Icon: Display.Icon.None Buttons: Display.Buttons.OK DefaultButton: Display.DefaultButton.Button1 IsTopMost: False ButtonPressed=> ButtonPressed

     


    Thanks,
    Deenuji Loganathan 👩‍💻
    Automation Evangelist 🤖
    Follow me on LinkedIn 👥

    -------------------------------------------------------------------------------------------------------------
    If I've helped solve your query, kindly mark my response as the solution ✔ and give it a thumbs up!👍 Your feedback supports future seekers 🚀. If you'd like to appreciate me, please write a LinkedIn recommendation 🙏

     

  • Nived_Nambiar Profile Picture
    18,138 Super User 2026 Season 1 on at

    Hi @bensat2 

     

    adding some additional point along with @Deenuji  flows

     

    Make sure to close all the connections opened in flow (like sql connection and others) before using stop flow action.

     

    Thanks & Regards,

    Nived N 🚀

    LinkedIn: Nived N's LinkedIn
    YouTube: Nived N's YouTube Channel
    Blog: Nived Nambiar's Blogs

    🔍 Found my answer helpful? Please consider marking it as the solution!
    Your appreciation keeps me motivated. Thank you! 🙌

     

  • Agnius Bartninkas Profile Picture
    Most Valuable Professional on at

    Or, better yet, simply not use the Open SQL connection action at all. It's not necessary - the connection string can be used directly in the Execute SQL statement action, and there won't be any need to close the connection afterwards, as it closes automatically after the statement is executed.

  • bensat2 Profile Picture
    75 on at

    Ca uu you elaborate how we can have connection string in execute statement

     

  • Verified answer
    Agnius Bartninkas Profile Picture
    Most Valuable Professional on at

    If you select "Connection string" in the drop down next to "Get connection by", you can type in (or build) the connection string directly within the action, instead of using a connection variable.

    Agnius_1-1712048270175.png

     

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Automate

#1
Mohsin Ali Profile Picture

Mohsin Ali 389

#2
11manish Profile Picture

11manish 345 Super User 2026 Season 2

#3
M Bilal Khan Profile Picture

M Bilal Khan 308

Last 30 days Overall leaderboard