Connect to SQL Server from Power Apps

SQL Server icon.

Connect to SQL Server, in either Azure or an on-premises database, so that you can manage your data with create, read, update, and delete operations.

Note

Newly created SQL data sources are no longer prefixed with "[dbo]" as they have been in previous versions of Power Apps. See the common issues and resolutions page for more information.

Prerequisites

  • Sign up for Power Apps, and then sign in by providing the same credentials that you used to sign up.

  • Gather the following information for a database that contains at least one table with a primary key:

    • the name of the database

    • the name of the server on which the database is hosted

    • a valid user name and password to connect to the database

    • the type of authentication needed to connect to the database

      If you don't have this information, ask the administrator of the database that you want to use.

  • For an on-premises database, identify a data gateway that was shared with you (or create one).

Generate an app automatically

  1. In Power Apps Studio, click or tap New on the File menu (along the left edge).

    New option on the File menu.

  2. Under Start with your data, click or tap the right arrow at the end of the row of connectors.

  3. If you already have a connection to the database that you want to use, click or tap it, and then skip to step 7 in this procedure.

  4. Click or tap New connection, and then click or tap SQL Server.

    Add SQL Server connection.

  5. Perform either of these steps:

    • Specify Connect directly (cloud services), and then type or paste the server name, the database name, the user name, and the password for the database that you want to use.

      Server details.

    • Specify Connect using on-premises data gateway, type or paste the server name, the database name, the user name, and the password for the database that you want to use, and specify the authentication type and the gateway.

      Connect to an on-premises database.

      Note

      If you don't have a gateway, install one, and then click or tap Refresh gateway list.

  6. Click or tap Connect.

  7. Click or tap an option under Choose a dataset, click or tap an option under Choose a table, and then click or tap Connect.

    Power Apps creates an app that shows data on three screens. Heuristics suggest what kind of data to show, but you might need to customize the UI to suit your needs.

  8. Customize the app by using techniques that are similar to those that Create an app from Excel describes, starting with changing the app layout.

Build an app from scratch

  1. Sign in to powerapps.com with the same account that you used to sign up for Power Apps.

  2. In the left navigation bar, click or tap Connections:

    Manage connections.

  3. In the upper-right corner, click or tap New connection, and then click or tap SQL Server.

  4. Perform either of these steps:

    • Specify Connect directly (cloud services), and then type or paste the server name, the database name, the user name, and the password for the database that you want to use.

      Connect directly (cloud services).

    • Specify Connect using on-premises data gateway, type or paste the server name, the database name, the user name, and the password for the database that you want to use, and specify the authentication type and the gateway.

      Connect using on-premises data gateway.

      Note

      If you don't have a gateway, install one, and then click or tap the clockwise icon to refresh the list.

  5. Click or tap Create to create the connection.

  6. Create an app by using techniques that are similar to those that Create an app from scratch describes.

Update an existing app

  1. In Power Apps Studio, open the app that you want to update.

  2. Click or tap Data sources on the View tab of the ribbon.

  3. In the right-hand pane, click or tap Add a data source.

    Add data source.

  4. Click or tap New connection, click or tap SQL Server, and then click or tap Connect.

  5. Perform either of these steps:

    • Specify Connect directly (cloud services), and then type or paste the server name, the database name, the user name, and the password for the database that you want to use.

      Connect to a database in Azure - cloud services.

    • Specify Connect using on-premises data gateway, type or paste the server name, the database name, the user name, and the password for the database that you want to use, and specify the authentication type and the gateway.

      Connect to a database in Azure.

      Note

      If you don't have a gateway, install one, and then click or tap the circular icon to refresh the list.

  6. Click or tap Connect.

  7. Under Choose a dataset, click or tap an option.

  8. Under Choose a table, select one or more checkboxes, and then click or tap Connect.

Next steps