Introduction
Just as our prehistoric ancestors evolved by adopting tools like fire and stone axes, your journey as a Power Apps developer must also evolve. As your experience grows, you’ll need to reach further and build more complex applications. One of the most significant milestones in this evolution is moving beyond SharePoint lists and connecting your apps to enterprise-level storage solutions like Microsoft SQL Server.
In this guide, I’ll walk you through the process of:
- Setting up an Azure SQL database
- Creating tables and relationships
- Connecting Power Apps to SQL using stored procedures and Power Automate
- Building a simple inventory and order management application
Let’s take our first steps into this bigger world of enterprise-level data management!
Prefer to Watch the Video?
Head over to my YouTube channel Chino Does Stuff to watch the video tutorial, there you will see a variety of videos with loads of tricks and tips on the entire Power Platform suite.
Why move beyond SharePoint lists?
SharePoint lists are a fantastic place to start, and for plenty of apps they’re all you’ll ever need. (If you’re curious how far they can stretch, see using SharePoint lists like a relational database.) But sooner or later an app outgrows them, and a proper database starts to earn its keep.
Real relationships
A foreign key makes the database check that every order belongs to a real stock item, instead of relying on lookup columns and good habits.
Room to grow
Databases are built for large, busy tables with indexes, so a list that keeps growing stops being a worry.
Rules in one place
Data types, constraints and procedures apply to every app and report that touches the data, not just the one you built first.
Finer security
Firewall rules, database users and permissions give you more precise control over who and what can reach the data.
How the pieces fit together
Three pieces do the work. The Power App is what people see. The Azure SQL database stores the data. Power Automate sits in the middle and carries requests and results between them. Power Apps can also talk to SQL directly, which we’ll cover below.
Microsoft’s documentation describes calling SQL Server stored procedures straight from Power Fx, so a flow is no longer the only way in. We’ll still use one here, because a flow is the natural home for multi-step processes and it’s the approach shown in the video. Later on you’ll see the direct version too.
Works well
- Reading tables and views straight into galleries and forms
- Calling stored procedures for joins and business rules
- Using a flow when a process has several steps
- Keeping the rules in SQL, where every app can reuse them
Needs care
- Complex joins written in Power Fx. SQL is better at them
- Pulling very large tables whole into the app
- Shared connections, because users typically share one set of credentials
- Premium licensing, so confirm before you build
Which data source fits your app?
SQL isn’t always the right answer. Work through the two questions below, then check the comparison table for the detail.
| Feature | SharePoint list | Dataverse | Azure SQL database |
|---|---|---|---|
| Best for | Simple data and small teams already in Microsoft 365 | Apps that live entirely inside the Power Platform | Data shared with other systems, larger tables, or existing SQL skills |
| Relationships | Lookup columns, with limited enforcement | Built-in tables and relationships | Foreign keys, constraints and joins in SQL |
| Security model | SharePoint permissions | Dataverse security roles | Firewall rules, database users and permissions |
| Skills needed | Low | Medium | SQL knowledge helps a lot |
| Licensing | Often covered by Microsoft 365 for standard use | Usually needs premium Power Apps licensing | SQL Server connector is generally premium, plus Azure costs |
Licensing and limits change, so treat this table as a starting point and confirm the current details with Microsoft.
Setting Up Your Azure SQL Database
The first step is to set up an Azure SQL database. If you’re new to Azure, you can sign up for a free trial which gives you plenty of credits to explore the platform.
Creating a SQL Server and Database
In the Azure Portal:
Find SQL databases
In the Azure Portal, search for “SQL databases” and select Create (older versions of the portal say Add).
Choose a resource group
Select an existing resource group or create a new one.
Pro tipA dedicated resource group keeps everything for this project together and makes clean-up easy.
Name your database
Give your database a name (for example, “ChinoDB”).
Create a SQL server
Create a new SQL server (for example, “ChinoDBSRV”). The server name becomes part of the address you connect to.
Pro tipServer names have to be unique across Azure, so pick something distinctive.
Set the admin credentials
Set up the server admin login and password.
Pro tipTreat this login as a setup tool. Your app gets its own limited user later in this guide.
Create it
Take the default options for the other settings and click Create.
Pro tipWhile you’re learning, choose a low-cost compute tier. You can scale up later.
Configuring Server Firewall Rules
Once your server and database are created, you need to configure the firewall:
Open your SQL server
Navigate to your SQL server in the Azure Portal.
Open Networking
Click on “Networking” under “Security”.
Allow Azure services
Set “Allow Azure services and resources to access this server” to “Yes”.
Pro tipThis setting admits connections from Azure services generally, not only yours. It suits learning, and it’s worth reviewing before production.
Add your client IP
Add your client IP address so you can connect from your desktop.
Pro tipRemove your IP again when you no longer need it.
// Azure SQL Server Configuration
// 1. Create SQL Server
Server name: your-server-name.database.windows.net
Server admin login: YourAdminUsername
Password: YourSecurePassword
// 2. Configure Firewall
- Set "Allow Azure services and resources to access this server" to YES
- Add your client IP address for local developmentThis firewall configuration is crucial as it allows Power Apps and Power Automate to connect to your database, while also letting you manage the database from your local computer.
Creating Your Database Structure
For this tutorial, we’ll create a simple inventory management system with two tables: a Stock table for inventory items and an Orders table for tracking restock orders.
Connecting to Your Database
To manage your database, you’ll need SQL Server Management Studio (SSMS):
- Download and install SQL Server Management Studio
- Connect to your database using the server name, admin username, and password
Creating Tables
We’ll create two tables with a simple relationship:
-- Create Stock Table
CREATE TABLE Stock (
ID int IDENTITY(1,1) PRIMARY KEY,
Name varchar(100) NOT NULL,
Description varchar(255),
StockLevel int
);
-- Create Orders Table
CREATE TABLE Orders (
ID int IDENTITY(1,1) PRIMARY KEY,
StockID int NOT NULL,
OrderDate datetime,
Amount int,
Description varchar(255),
CONSTRAINT FK_Orders_Stock FOREIGN KEY (StockID) REFERENCES Stock (ID)
);Let’s break down what we’ve done:
- Stock Table: Stores inventory items with a name, description, and current stock level
- Orders Table: Tracks order history with references to stock items
- Relationships: The StockID in Orders refers to the ID in Stock, creating a one-to-many relationship. The FOREIGN KEY line is what makes the database enforce it
Populating Sample Data
To make testing easier, let’s add some sample data to our tables:
-- Insert sample stock items
INSERT INTO Stock (Name, Description, StockLevel)
VALUES
('Resistor', '10K Ohm Resistor', 50),
('Capacitor', '10uF Electrolytic Capacitor', 30),
('Diode', '1N4007 Diode', 25);
-- Insert sample orders
INSERT INTO Orders (StockID, OrderDate, Amount, Description)
VALUES
(1, GETDATE(), 20, 'Monthly resistor order'),
(2, GETDATE(), 15, 'Low stock capacitor order'),
(3, GETDATE(), 30, 'Diode replacement order'),
(1, DATEADD(day, -7, GETDATE()), 25, 'Emergency resistor order');Creating a Stored Procedure
Here’s where things get interesting. Power Fx can’t express everything SQL can, so rather than asking the app to stitch two related tables together, we’ll create a stored procedure that joins the data for us:
CREATE PROCEDURE GetOrders
AS
BEGIN
SET NOCOUNT ON;
SELECT
t2.Name AS StockName,
t2.Description AS StockDescription,
t1.Amount AS OrderedAmount,
t1.Description AS OrderDescription,
t1.OrderDate AS OrderDate
FROM Orders t1
JOIN Stock t2 ON t1.StockID = t2.ID
ORDER BY t1.OrderDate DESC;
ENDThis stored procedure joins the Orders and Stock tables, giving us a flattened view that’s perfect for displaying in Power Apps. Two small additions to the version in the video: SET NOCOUNT ON stops SQL sending row-count messages the app doesn’t need, and ORDER BY puts the newest orders first. Because every order must have a stock item, a plain JOIN is right. Use LEFT JOIN if orders could exist without one.
Giving the app its own database user
Before the flow connects, create a limited user so the app never needs the admin login:
-- Run in your database (not master). Adjust to your security policy.
CREATE USER PowerAppsUser WITH PASSWORD = 'Use-a-long-random-password-here';
-- Give the app user only what it needs
GRANT EXECUTE ON OBJECT::dbo.GetOrders TO PowerAppsUser;Connecting Power Apps to SQL Using Power Automate
Power Apps can now call SQL stored procedures directly, but Power Automate is still a reliable bridge between an app and a database, especially when a process has more than one step. Here we’ll use it as that bridge.
Creating a Power Automate Flow
Here’s how to set up the flow:
Create an instant flow
Create a new instant flow with the Power Apps trigger.
Add Execute stored procedure
Add an “Execute stored procedure” action from the SQL Server connector.
Pro tipIf you see more than one version of the action, choose the newest (V2).
Point it at GetOrders
Configure it to connect to your database and call the “GetOrders” procedure.
Pro tipCreate the connection with the limited app user from the previous section, not the admin login.
Parse the response
Add a “Parse JSON” action to format the response.
Pro tipRun the flow once, copy the JSON output, and use Generate from sample to build the schema for you.
Respond to Power Apps
Add a “Respond to PowerApps” action to return the data.
Pro tipIf the action only offers simple outputs, return the rows as text with string() and convert them in the app with ParseJSON.
// Power Automate Flow Steps:
1. Trigger: PowerApps
- Initialize flow from Power Apps
2. Execute Stored Procedure
- Server name: your-server-name.database.windows.net
- Database name: YourDatabaseName
- Procedure name: GetOrders
3. Parse JSON
- Content: Body from Execute Stored Procedure step
- Schema: (Use the output schema from a test run)
4. Respond to PowerApps
- Return the parsed JSON result to Power AppsThe key here is the “Parse JSON” step. When you execute the flow for the first time, you can copy the JSON output from the stored procedure execution and use it to generate the schema automatically.
Building Your Power App
With the database and flow set up, we can now build our Power App:
Create a New Canvas App
Create a blank canvas app
Start from a blank canvas app.
Add a gallery control
The gallery will list your orders.
Add a button to refresh data from SQL
The button runs the flow and loads the results.
Setting Up Data Retrieval
Configure the button to call your flow and store the results:
// Power Apps Gallery Setup
// 1. Create a variable to store SQL data
Set(
SQLOrderData,
PowerAutomateFlow.Run('GetOrders').ResultSet.Table1
);
// 2. Set Gallery.Items property
Gallery1.Items = SQLOrderData;
// 3. In gallery controls, use ThisItem properties:
// - ThisItem.StockName
// - ThisItem.StockDescription
// - ThisItem.OrderedAmount
// - ThisItem.OrderDescription
// - ThisItem.OrderDateThe names after .Run() depend on how your flow responds, so use the suggestions in the formula bar to match your own flow. If you’d rather skip the flow, add the SQL Server connection to your app and call the procedure directly:
// Option B: call the stored procedure directly
// (add the SQL Server connection to the app first)
Set(
SQLOrderData,
ChinoDB.dboGetOrders().ResultSets.Table1
);The connection name and procedure name will appear in the formula bar suggestions, so you don’t need to guess them.
Displaying the Data
In your gallery, add labels to display the data:
- Add a label for the stock name
- Add a label for the order description
- Add a label for the order amount
- Add a date picker (in view mode) for the order date
Common mistakes to avoid
Most problems with a first SQL-backed app come from the same handful of habits. Here’s what to avoid, and what to do instead.
Connecting with the admin login
One leaked or over-trusted login then opens the whole server.
InsteadCreate a dedicated database user for the app and grant only what it needs, such as EXECUTE on GetOrders.
Skipping the foreign key
Without it, nothing stops an order pointing at a stock item that doesn’t exist.
InsteadDeclare the FOREIGN KEY so the database refuses orphan rows for every app and report.
Opening the firewall to everyone
A wide-open rule is convenient while testing and easy to forget.
InsteadAllow only the Azure services you need and your own IP address, and remove old test IPs.
Pulling the whole table into the app
Every extra row makes the app slower and the screen harder to use.
InsteadJoin, filter and sort in the stored procedure, and return only what the screen shows.
Storing dates and numbers as text
Text sorts alphabetically, so “10” lands before “9” and dates drift out of order.
InsteadUse real data types such as datetime and int so sorting, filtering and maths behave.
Before you go live
- The app connects with a limited database user, not the admin login
- Firewall rules allow only what you need, and old test IPs are gone
- Every relationship has a FOREIGN KEY constraint
- Columns use proper data types
- Stored procedures return only the rows and columns the app needs
- You’ve tested empty results and a large number of rows
- Passwords live in a password manager, not in screenshots or flow notes
- You’ve confirmed licensing for everyone who will use the app
Beyond the Basics: Creating a Complete Application
While we’ve covered the fundamentals of connecting Power Apps to SQL, a complete application would include:
Create/Edit Forms
Screens to add and update stock items and orders. Call a stored procedure or flow for each save, so the rules stay in SQL.
Data Validation
Ensuring data integrity before saving to SQL. Check in the app for fast feedback, and again in the database as the safety net.
Automatic Reordering
Triggering orders when stock levels fall below thresholds. A scheduled flow can compare StockLevel with a minimum and raise the order.
User Authentication
Ensuring only authorised users can access certain functions. Control who can open the app, and keep the database user’s permissions tight.
Key Takeaways for Working with SQL in Power Apps
As you continue to develop with SQL and Power Apps, remember these important points:
Use Stored Procedures
They’re the key to working effectively with SQL, especially with related tables.
Power Automate is Your Bridge
Use it to connect Power Apps with SQL stored procedures, especially when a process has several steps.
Secure Your Database
Create specific database users for your apps rather than using admin credentials.
Plan Your Data Model
A well-designed database schema makes app development much easier.
Learn SQL Basics
Understanding SQL queries and joins will dramatically expand what you can do with Power Apps.
Want a hand with Power Apps and SQL?
Office Experts Group is an Australian Microsoft consultancy, established in 2000. If you’d like help designing the database, building the app or tidying up an existing one, tell us about your project.
Talk to our teamFrequently asked questions
Do I need a premium licence to use SQL with Power Apps?
The SQL Server connector is generally classed as a premium connector, which usually means the people using the app need a Power Apps or Power Automate plan that includes premium connectors. Licensing changes over time, so confirm with Microsoft or your licensing partner before you build.
Can Power Apps call a SQL stored procedure without Power Automate?
Yes. Microsoft documents calling SQL Server stored procedures directly from Power Fx through the SQL Server connector. A flow is still a good bridge when a process has several steps, such as saving a record, emailing someone and updating a second system.
Why use a stored procedure instead of connecting to the tables?
Power Fx is great for simple queries but it can’t express everything SQL can. A stored procedure (or a view) lets the database do the joins, filtering and sorting, so the app receives one tidy result. Procedures are also the usual place for create, update and delete logic.
Can I use an on-premises SQL Server instead of Azure SQL?
Yes, but the connection is different. An on-premises SQL Server is normally reached through an on-premises data gateway, and the firewall steps in this guide won’t apply. Your IT team will need to set up and maintain the gateway.
Is it safe to use the admin login in my app?
No. Create a dedicated database user with the minimum permissions the app needs. As a rule, the connection’s credentials are shared by everyone who uses the app, so control who can open the app and what that database user is allowed to do.
Conclusion
Moving from SharePoint lists to SQL databases is a significant evolution in your Power Apps journey. While there’s certainly a learning curve, the benefits are substantial:
- More sophisticated data relationships
- Better performance with large datasets
- Advanced data validation and business logic at the database level
- Enterprise-grade security and scalability
This tutorial covered the core functionality of using SQL with Power Apps, but there’s much more to explore. In future tutorials, we’ll build on this foundation to create more complete applications with full CRUD (Create, Read, Update, Delete) capabilities.
If you’d like to see more Power Apps development tutorials using SQL, please head over to the YouTube channel and leave a comment there. I actively monitor and respond to all YouTube comments!





