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 / Flow for SQL data mont...
Power Automate
Unanswered

Flow for SQL data monthly updating

(1) ShareShare
ReportReport
Posted on by 36

I am currently updating an Excel file from SQL monthly. My query starts from a With() for CTE which includes date range last month (like between '2024-06-01' and '2024-06-30'), it runs like less than 10 minutes if the dates are hardcoded, or like forever if  I declare the variables using formulas to get the dynamic date:  

@StartDate as date = datefromparts( Year( DATEADD(month, -1, getdate())), Month(DATEADD(month, -1, getdate())), 1) 

@EndDate as date =  eomonth(@startdate) 

which never works on SQL takes 2-3 hours and tell me Timeout or lost connection ...  

 

I wish i could make an automation for it by creating a flow, get the startdate and enddate in the flow and use them in the sql query: 

MiaSunny_0-1720549721225.png

MiaSunny_3-1720550407793.png

both dates are string since no date type in power automate. 

I am using the same sql query and insert the 2 variables in the cte. it's not really difficult just with some "case when", joins and one date range: 

MiaSunny_1-1720549791359.png

but it takes more than 3 hours to run the flow, my first try failed with a 502 bad gateway -- i could get data from sql but takes a long time, the info should not be wrong; or if the db name or table name not correct i don't think it should take 3.5 hours to know. 

MiaSunny_2-1720549922730.png

I am not using desktop since my license doesn't support running in the backend and wondering if cloud flows could help with this. -- i only want it runs monthly and append to an Excel in sharepoint as a quick resource, no more manually inputs.  

And, is it possible to use power automate to build the code like hardcoded, or it works just like variables? 

 

Thank you! 

 

Categories:

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
11manish Profile Picture

11manish 317 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 247

#3
Henil Profile Picture

Henil 117

Last 30 days Overall leaderboard