Business Professionals
Power BI | Power Pivot | Power Query | DAX
Cloud Flows | RPA | AI Builder | Copilot
60+ Formulas | Data Stories | Advanced Reporting & Modeling
VB Programming | Report Automation |
MS-Office Automation
Techno-Business Professionals
Power BI | Power Query | Advanced DAX | SQL - Query &
Programming
Microsoft Fabric | Power BI | Power Query | Advanced DAX |
SQL - Query & Programming
Power BI | Power Apps | Power Automate | Copilot Studio | Power Pages | Dataverse
Microsoft Power Apps | Microsoft Power Automate
Power BI | Adv. DAX | SQL (Query & Programming) |
VBA | Python | Web Scrapping | API Integration
Power BI | Power Apps | Power Automate |
SQL (Query & Programming)
Power BI | Adv. DAX | Power Apps | Power Automate |
SQL (Query & Programming) | VBA | Python | Web Scrapping | API Integration
Power Apps | Power Automate | SQL | VBA | Python |
Web Scraping | RPA | API Integration
Technology Professionals
Power BI | DAX | SQL | ETL with SSIS | SSAS | VBA | Python
Power BI | SQL | Azure Data Lake | Synapse Analytics |
Data Factory | Databricks | Power Apps | Power Automate |
Azure Analysis Services
Microsoft Fabric | Power BI | SQL | Lakehouse |
Data Factory (Pipelines) | Dataflows Gen2 | KQL | Delta Tables | Power Apps | Power Automate
Power BI | Power Apps | Power Automate | SQL | VBA | Python | API Integration
Power BI | Advanced DAX | Databricks | SQL | Lakehouse Architecture
Business Professionals
Power BI | Power Pivot | Power Query | DAX
Cloud Flows | RPA | AI Builder | Copilot
60+ Formulas | Data Stories | Advanced Reporting & Modeling
VB Programming | Report Automation |
MS-Office Automation
Techno-Business Professionals
Power BI | Power Query | Advanced DAX | SQL - Query &
Programming
Microsoft Fabric | Power BI | Power Query | Advanced DAX |
SQL - Query & Programming
Power BI | Power Apps | Power Automate | Copilot Studio | Power Pages | Dataverse
Microsoft Power Apps | Microsoft Power Automate
Power BI | Adv. DAX | SQL (Query & Programming) |
VBA | Web Scrapping | API Integration
Power BI | Power Apps | Power Automate |
SQL (Query & Programming)
Power BI | Adv. DAX | Power Apps | Power Automate |
SQL (Query & Programming) | VBA | Web Scrapping | API Integration
Power Apps | Power Automate | SQL | VBA |
Web Scraping | RPA | API Integration
Technology Professionals
Power BI | DAX | SQL | ETL with SSIS | SSAS | VBA
Power BI | SQL | Azure Data Lake | Synapse Analytics |
Data Factory | Azure Analysis Services
Microsoft Fabric | Power BI | SQL | Lakehouse |
Data Factory (Pipelines) | Dataflows Gen2 | KQL | Delta Tables
Power BI | Power Apps | Power Automate | SQL | VBA | API Integration
Power BI | Advanced DAX | Databricks | SQL | Lakehouse Architecture
LEARN THIS HANDS ON
Power Apps & Power Automate
You build a flow that updates SQL and sends Teams alerts, it works in dev, and then fails randomly in production with vague gateway errors and partial updates. The data is on-prem, the automation is in the cloud, and the gap between the two is where reliability goes to die. This article shows how to design robust hybrid flows with Power Automate and on-prem SQL Server, so your automations behave predictably instead of failing under load.
We’ll use one realistic scenario throughout: an operations team with an on-prem SQL line-of-business database and Power Automate flows that:
The goal is to move from brittle, hard-to-debug flows to a pattern that is resilient to gateway hiccups, network issues, and SQL lock contention.
The operations team has a flow:
Orders table via SQL connector.Symptoms:
BadGateway or GatewayTimeout errors.Constraints:
We’ll fix this by focusing on four areas:
If the gateway is unstable, no amount of clever flow logic will save you.
For production, rely on a gateway cluster, not a single gateway instance:
Power Automate uses the cluster to distribute load and handle failover when one gateway node is unavailable. This doesn’t auto-retry a failed SQL action, but it reduces outright connection failures.
To reduce latency and timeouts:
High latency plus large result sets is a common cause of slow or failing SQL actions.
When configuring the SQL connector connection for on-prem:
INSERT, UPDATE, DELETE as neededSELECT rights (prefer stored procedures or views)sa or other high-privilege accounts; this increases blast radius of mistakes.For hybrid reliability, prefer stored procedures over ad-hoc INSERT/UPDATE actions in the flow. This lets SQL handle transactions and error handling closer to the data.
The SQL connector in Power Automate has specific behavior that affects reliability:
In our scenario, the original flow:
Insert row for each row individuallyProblems:
Better pattern:
Create a stored procedure that:
Example: using a table-valued parameter for orders.
CREATE TYPE dbo.OrderImportType AS TABLE
(
OrderNumber nvarchar(50) NOT NULL,
CustomerCode nvarchar(50) NOT NULL,
OrderDate date NOT NULL,
Amount decimal(18, 2) NOT NULL
);
GO
CREATE PROCEDURE dbo.ImportOrders
@BatchId uniqueidentifier,
@Orders dbo.OrderImportType READONLY
AS
BEGIN
SET NOCOUNT ON;
BEGIN TRY
BEGIN TRANSACTION;
INSERT INTO dbo.Orders
(
BatchId,
OrderNumber,
CustomerCode,
OrderDate,
Amount
)
SELECT
@BatchId,
OrderNumber,
CustomerCode,
OrderDate,
Amount
FROM @Orders;
COMMIT TRANSACTION;
SELECT 1 AS Success, 'OK' AS Message;
END TRY
BEGIN CATCH
IF @@TRANCOUNT > 0
ROLLBACK TRANSACTION;
SELECT
0 AS Success,
ERROR_MESSAGE() AS Message;
END CATCH;
END;
GO
This gives you:
In Power Automate, call this procedure with the Execute stored procedure action and pass a batch ID and a table-valued parameter.
Note: the SQL connector supports table-valued parameters when the stored procedure and connection are configured appropriately; if your environment doesn’t, you can pass JSON as nvarchar(max) and parse it in SQL.
Even with a solid gateway and stored procedures, hybrid flows must assume:
In the scenario, one file may be processed twice if:
Introduce a BatchId:
Orders table.Example SQL constraint:
ALTER TABLE dbo.Orders
ADD CONSTRAINT UQ_Orders_Batch_OrderNumber
UNIQUE (BatchId, OrderNumber);
If the flow retries with the same BatchId and OrderNumber, the insert fails, but the stored procedure can treat this as a duplicate rather than a hard failure.
Original flow problem:
Fix:
ImportOrders stored procedure.Success flag.Success = 1.This ensures downstream actions reflect the actual database state as reported by SQL.
For SQL actions in Power Automate, you can configure the retry policy:
Use retries when:
Avoid retries when:
In our pattern, the stored procedure with BatchId and uniqueness constraints makes the operation effectively idempotent, so retries are safer. Still, keep retry counts modest to avoid hammering the gateway during outages.
Hybrid flows often break when multiple runs hit the gateway and SQL simultaneously.
For the SharePoint When a file is created trigger:
On and choose a reasonable degree of parallelism (often 1–3 for on-prem SQL).This prevents dozens of file-based runs from hitting SQL at once.
If a single file contains many rows:
This balances transaction size and lock duration on SQL:
The right batch size depends on your SQL hardware and schema; start with a moderate size and adjust based on observed performance.
Reading large datasets out of on-prem SQL through the gateway is a common source of slow runs and timeouts.
Prefer patterns where:
If you must move large datasets, consider:
Reliable hybrid flows need good visibility when things go wrong.
In the scenario, add logging in two places:
Flow-level logging
FlowRuns) in SQL.RunId (flow run ID)BatchIdStatus (Started, Succeeded, Failed)ErrorMessage (on failure)Example insert in SQL (called from the flow):
INSERT INTO dbo.FlowRuns
(
RunId,
BatchId,
Status,
ErrorMessage,
LoggedAt
)
VALUES
(
@RunId,
@BatchId,
@Status,
@ErrorMessage,
SYSUTCDATETIME()
);
SQL-level logging
ImportOrders, log failures to an OrderImportErrors table.This gives you a full picture when comparing Power Automate run history with SQL state.
Wrap your SQL actions in a Scope and configure Run After conditions:
ImportOrdersScope containing the stored procedure call.NotifySuccessScope that runs only if ImportOrdersScope is Succeeded.NotifyFailureScope that runs if ImportOrdersScope is Failed or Timed out.This avoids orphan notifications and gives a clean separation of success vs failure handling.
For critical SQL actions:
Set alerts:
Before:
Insert row to OrdersAfter:
BatchId and capture RunId.Started to FlowRuns.ImportOrders (e.g., table-valued parameter or JSON).ImportOrders via Execute stored procedure.Success:
Succeeded, send Teams notification.Failed, send alert to support.Result:
BatchId.When using Power Automate with on-prem SQL through the gateway, treat SQL as the system-of-record for transactions and idempotency, and use the flow mainly to orchestrate calls and react to the success/failure signals. Moving critical logic into stored procedures, adding a batch ID, and tightening concurrency and error handling around the SQL actions is usually the single biggest shift that turns unreliable hybrid flows into something you can trust in production.
This article reflects the shift from ad-hoc, row-by-row gateway calls to transaction-centric, stored-procedure-based patterns for Power Automate with on-prem SQL, which matters most in teams running production flows against line-of-business databases that can’t yet move fully to the cloud.
Professionals who want to apply these patterns to their own data can explore Excelgoodies' Power Automate Course programme - taught live by instructors, with certification awarded once a real project is running at work.
Insights compiled through ongoing industry research and discussions within the Excelgoodies Analytics Community.
Power Automate
New
Next Batches Now Live
Power BI
SQL
Power Apps
Power Automate
Microsoft Fabrics
Azure Data Engineering