DataMosaic

Blog · How-to

Connect Power Automate to an on-premises SQL Server, step by step

The gateway, the connection, a read-only login and the first scheduled flow, every step from Microsoft Learn, plus the limits that decide how you write the query.

#What you need before you start

Microsoft Learn lists these, in November 2026:

  • A licence that includes premium connectors. The SQL Server connector is Premium in Power Automate. Power Automate's pricing page lists Premium at $15.00 per user a month and Process at $150.00 per bot a month, both paid yearly; the free trial has "standard connectors only".
  • A Windows machine for the gateway. At least .NET Framework 4.8 on Windows 10, Windows 11 or Windows Server 2019, 2022 or 2025. Microsoft recommends 8 CPU cores, 8 GB of memory and a 64-bit Windows Server. Not a Server Core installation, not a Windows container, and not a domain controller.
  • A machine that never sleeps. In Microsoft's words: "Don't install a gateway on a computer, like a laptop, that might be turned off, asleep, or disconnected from the internet." A wired network is recommended.
  • Admin rights on that machine, and a work or school account in the same Microsoft 365 tenant as Power Automate.
  • A login on SQL Server for the flow. The next section creates one that can run a single procedure and nothing else.

The gateway needs no inbound firewall rule. It opens the connection out to Microsoft's cloud, which is usually what gets it past a security review.

#Is the gateway deprecated?

No, not on Microsoft's own pages. The gateway overview for Power Automate was updated in 2026 and says nothing of retiring it. What is marked [DEPRECATED] in the SQL Server connector reference are the first versions of its actions and triggers, such as Get rows [DEPRECATED], each replaced by a (V2) action, and the old Default [DEPRECATED] authentication type. If an old flow shows those, rebuild the step with the V2 action.

#Step 1: a login and a procedure on SQL Server

Through a gateway, Microsoft lists these limits for the connector:

  • Execute a SQL query (V2): "Not supported for on-premises SQL Server or connections with gateway."
  • A stored procedure called through a gateway returns only its first result set, no OUTPUT values and no return value, and its result set is untyped.
  • A query or procedure that runs longer than 110 seconds times out.
  • Requests are capped at 2 MB and responses at 8 MB.
  • date, datetime, datetime2 and smalldatetime columns "can't be used as query option predicates", so Get rows (V2) cannot filter on a business date.

That last one catches most people building a nightly flow. The way round it, and round the missing query action, is a stored procedure that does the filtering and the totals on the server. Run this in SSMS on the database the flow reads, here an invented POS_HQ, with your own table and column names:

USE POS_HQ;
GO

-- A SQL login for the flow. Needs the server to allow SQL Server authentication.
CREATE LOGIN flow_reader WITH PASSWORD = 'Replace-with-a-long-passphrase-2026';
GO
CREATE USER flow_reader FOR LOGIN flow_reader;
GO

CREATE PROCEDURE dbo.usp_store_day_sales
    @business_date date
AS
BEGIN
    SET NOCOUNT ON;

    SELECT store,
           COUNT(*)        AS receipts,
           SUM(net_amount) AS net_sales
    FROM dbo.pos_receipts
    WHERE business_date = @business_date
    GROUP BY store
    ORDER BY store;
END;
GO

-- The flow can run this one procedure, and read nothing else.
GRANT EXECUTE ON dbo.usp_store_day_sales TO flow_reader;
GO

Because the procedure and the table have the same owner, flow_reader needs no rights on pos_receipts itself. One result set, with a name on every column, is what the connector wants: Microsoft notes that a result set's column names must be unique and not empty. If the procedure takes more than a few seconds on a full day, add an index on business_date before the 110-second limit finds it for you.

To use Windows authentication instead, skip the login and grant EXECUTE to a domain account. The gateway then has to sit on a domain-joined machine in the same environment as SQL Server, or one whose domain the server's domain trusts, and the connector requires a gateway for that authentication type.

#Step 2: install the on-premises data gateway

From Install an on-premises data gateway:

  1. On the gateway machine, download the standard gateway. The personal mode gateway works only with Power BI, so Power Automate cannot use it.
  2. In the installer, keep the default path, accept the terms of use and select Install.
  3. Enter the email address of your work account and select Sign in.
  4. Select Register a new gateway on this computer, then Next.
  5. Enter a name for the gateway, unique in your tenant, and a recovery key. Store the key somewhere safe: Microsoft cannot retrieve it, and you need it to move or restore the gateway.
  6. Check the region the gateway connects to. The installer lets you change it on the same screen; Microsoft notes that changing it restricts the regions where the gateway can be used.
  7. Select Configure, review the summary and select Close.

Then sign in to Power Automate and open Data › Gateways. Your gateway should be in the list.

A single gateway is a single point of failure. Microsoft's answer is a cluster: install the gateway on a second machine, choose Add to an existing gateway cluster, pick the first gateway and enter its recovery key. Power Automate uses the primary and moves to the next one when the primary is unavailable.

#Step 3: the SQL Server connection

From Manage connections and the connector reference:

  1. In Power Automate, go to Data › Connections and select New connection.
  2. Search for SQL Server and select it.
  3. Choose the authentication type: SQL Server Authentication for the login above, or Windows Authentication for a domain account.
  4. Fill in SQL server name, SQL database name, Username and Password. Write the server name as the gateway machine sees it on your network, not as it is reached from outside.
  5. Under Gateway, pick the gateway from step 2.
  6. Save the connection.

The connection now appears under Data › Connections. If a password changes later, the connection shows Fix connection there, and every flow using it fails until you update it.

#Step 4: the first flow that reads rows

From Run a cloud flow on a schedule:

  1. Go to My flows, select Create from blank, then the Add a trigger node.
  2. Search for Recurrence and select it. Set Interval to 1 and Frequency to Day.
  3. Set Time zone to your own, and choose 6 under At these hours and 0 under At these minutes.
  4. Add an action, search for SQL Server and choose Execute stored procedure (V2). It uses the connection from step 3.
  5. Set Server name and Database name from the connection, Procedure name to [dbo].[usp_store_day_sales], and business_date to yesterday, with this expression:
formatDateTime(addDays(convertFromUtc(utcNow(), 'GMT Standard Time'), -1), 'yyyy-MM-dd')
  1. Because the result set is untyped through a gateway, the designer does not offer its columns as dynamic content. Add a Parse JSON action on the procedure's ResultSets output, and generate the schema from a sample run.
  2. Add what the flow should do with the rows: a table in an email, a row in a SharePoint list, a file.
  3. Save, then select Test and run it by hand once.

Put your own time zone in the expression: without convertFromUtc, a flow at 06:00 in a zone ahead of UTC can ask for the day before yesterday.

To test the connection before the procedure exists, use Get rows (V2) on a small table with Top Count set to 5. It reads a table, filters with OData in Filter Query and sorts with Order By, which Microsoft recommends setting so that rows come back in a fixed order.

#When a run fails

Add a step that emails IT and set its Run after to the SQL step having failed or timed out. Without it, a failed run is noticed when somebody looks at the flow's run history, or when the owner reads the repair tips Power Automate emails. The n8n vs Power Automate post covers retries and Try and Catch scopes in more detail.

#A week of the flow, worked through

An invented chain of 120 stores runs the flow at 06:00 to email head office yesterday's sales per store from POS_HQ. Here is a week of runs and what was true in the ERP the same morning.

MorningFlow runWhat the email saidWhat was true
MondaySucceeded120 stores, ST-014 at 12,400.00The ERP had 11,920.00 for ST-014, 480 apart
TuesdayFailedNothing; IT got the failure emailThe gateway machine had restarted for updates
WednesdaySucceeded119 storesST-022 sent 6,410.75 to the tills server late; it was missing in the ERP too
ThursdayFailedNothingMonth-end load made the procedure run past 110 seconds
FridaySucceeded120 stores, ST-031 at 8,120.00The ERP had 8,119.96, 0.04 of rounding

Invented figures. The flow did its job every day it ran: it read the rows it was asked for and sent them. The two failures were plain to see, because of the Run after step. The three runs marked Succeeded are the ones worth a second look. ST-014 was 480 short in the ERP, and nothing in the flow compared the two systems. ST-022 was missing from both, which a list of 119 stores does not say out loud. ST-031's 0.04 needed no action at all. A flow moves rows; telling whether two systems agree, and why not, is a separate job you would have to build inside it.

#Where the flow stops

At this point you have a working connection and a flow that reads your own SQL Server every morning, without Mosaic. To compare the POS with the ERP inside Power Automate, you would read both, loop over 120 stores, handle a store present on one side only, write down a tolerance, and keep yesterday's result to set against today's. The queries for that comparison are in compare two tables in SQL.

DataMosaic does that job. It can run on a machine inside your network, where it reads SQL Server directly over its own port with a read-only login, so there is no gateway in between. A check reads two systems, lines their rows up on a key such as store and business date, and shows each store as matched, differing or missing. Rules decide whether a run passed, so ST-031's 0.04 does not fail it. On a differing row, an investigation goes through the reasons a system can refuse or miss data, until there is a reason for ST-014. A check only reads. Mosaic changes a system only through a workflow you build, started by a check, a schedule, a call or by hand. It is not a general automation tool: keep Power Automate for the flows that live in Microsoft 365. If you are weighing other tools for those, see the Power Automate alternatives post.

#Questions people ask

#Can Power Automate connect to an on-premises SQL Server without a gateway?

Not for a server that is only reachable inside your network. Power Automate runs in Microsoft's cloud, and the on-premises data gateway is how it reaches data on your own network.

#Why is Execute a SQL query (V2) not working with my gateway?

Microsoft's connector reference says it is "not supported for on-premises SQL Server or connections with gateway". Put the query in a stored procedure and call it with Execute stored procedure (V2), or use Get rows (V2) for a single table.

#Can I use Windows authentication with the SQL Server connector?

Yes. Choose Windows Authentication when you create the connection. It requires a gateway, installed on a domain-joined machine in the same environment as the SQL Server.

#Do I need a premium licence for the SQL Server connector?

Yes. The connector is premium in Power Automate, so the flow's owner needs Power Automate Premium or the flow needs a Process licence. The free trial has standard connectors only.

#Why does my SQL Server action time out?

The connector times out any query or stored procedure that runs longer than 110 seconds. Make the procedure faster, often with an index on the column you filter by, or have it read a smaller range.

Stop comparing exports by hand.

DataMosaic checks the systems themselves overnight, tells you why they differ, and runs the fix you've set up, before anyone else notices.