You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
description: Step-by-step instructions for how to connect to Azure SQL or an on-premises SQL Server database
3
+
description: Learn how to connect to Azure SQL or an on-premises SQL Server database.
4
4
author: lancedMicrosoft
5
5
6
6
ms.topic: reference
7
7
ms.custom: canvas
8
-
ms.date: 01/05/2024
8
+
ms.date: 2/28/2024
9
9
ms.subservice: canvas-maker
10
10
ms.author: lanced
11
11
ms.reviewer: mkaur
@@ -15,54 +15,86 @@ contributors:
15
15
- mduelae
16
16
- lancedmicrosoft
17
17
---
18
-
# Connect to SQL Server from Power Apps
19
-
20
-
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.
21
18
22
-
> [!NOTE]
23
-
> 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](/troubleshoot/power-platform/power-apps/common-issues-and-resolutions) page for more information.
19
+
# Connect to SQL Server from Power Apps
24
20
25
-
## Prerequisites
21
+
You can connect to SQL Server in either Azure or an on-premises database.
26
22
27
-
*[Sign up](../../signup-for-powerapps.md) for Power Apps, and then [sign in](https://make.powerapps.com?utm_source=padocs&utm_medium=linkinadoc&utm_campaign=referralsfromdoc) by providing the same credentials that you used to sign up.
28
-
* Gather the following information for a database that contains at least one table with a primary key:
29
-
30
-
* the name of the database
31
-
* the name of the server on which the database is hosted
32
-
* a valid user name and password to connect to the database
33
-
* the type of authentication needed to connect to the database
34
-
35
-
If you don't have this information, ask the administrator of the database that you want to use.
36
-
* For an on-premises database, identify a [data gateway](../gateway-management.md) that was shared with you (or create one).
23
+
> [!NOTE]
24
+
> Newly created SQL data sources are no longer prefixed with `[dbo]` like in previous versions of Power Apps.
25
+
>
26
+
> For more information, see [Common issues and resolutions for Power Apps](/troubleshoot/power-platform/power-apps/common-issues-and-resolutions).
37
27
38
28
## Generate an app automatically
39
29
40
-
41
-
Depending upon whether you have the [new look](../intro-maker-portal.md?tabs=home-new-look) or [classic look](../intro-maker-portal.md?tabs=home-classic) turned on, select the appropriate tab below to know more.
42
-
30
+
Depending on which Power Apps interface you're using, reference the [new look](../intro-maker-portal.md?tabs=home-new-look) or the [classic look](../intro-maker-portal.md?tabs=home-classic) to build an app.
43
31
44
32
1. Sign in to [Power Apps](https://make.powerapps.com?utm_source=padocs&utm_medium=linkinadoc&utm_campaign=referralsfromdoc).
45
-
1.Depending on how you want to create your app, from the home screen, select one of the following options:
33
+
1.From the **Home** page, select either the _single-page gallery_ or _three screen mobile_ option:
46
34
- To create a single-page gallery app with a responsive layout, choose either:
47
-
-**Start with data** > **Connect to external data** > **From SQL**.
48
-
-**Start with a page design** > **Gallery connected to external table** > **From SQL**.
35
+
-**Start with data** > **Select external data** > **From SQL**.
36
+
-**Start with a page design** > **Gallery connected to external data** > **From SQL**.
49
37
- To create a three screen mobile app, select **Start with an app template** > **From SQL**.
50
-
1. Select your SQL connection and then select a table. Note, that only one connection is shown at a time. To select a different connection, select on the **...** button to switch connection or create a new SQL connection.
38
+
1. Select your SQL connection and then select a table. To choose a different connection, select the **...** overflow menu to switch your connection or create a new SQL connection.
39
+
40
+
> [!NOTE]
41
+
> Only one connection is shown at a time.
51
42
1. When you're done, select **Create app**.
52
43
44
+
## Call stored procedures directly in Power Fx (preview)
45
+
46
+
You can directly call SQL Server stored procedures from Power Fx by turning on the SQL Server stored procedure preview switch.
47
+
48
+
1. Go to **Settings** > **Upcoming features** > **Preview**.
49
+
1. Search for _stored procedures_.
50
+
1. Turn on the preview switch as shown.
51
+
52
+
:::image type="content" source="media/connection-azure-sqldatabase/previewflag-call-sp-direct.png" alt-text="Screenshot that shows the SQL Server stored procedures toggle set to On.":::
53
+
54
+
When you add a SQL Server connection to your app, you can now add tables and views or stored procedures.
55
+
56
+
:::image type="content" source="media/connection-azure-sqldatabase/tables-views-stored-proc-selector.png" alt-text="Screenshot that shows lists of tables, views, and stored procedures available to be added to your app.":::
57
+
58
+
If you don't immediately see your stored procedure, it's faster to search for it.
59
+
60
+
Once you select a stored procedure, a child node appears and you can designate the stored procedure as **Safe to use for galleries and tables**. If you check this option, you can assign your stored procedure as an **Items** property for galleries for tables to use in your app.
61
+
62
+
Enable this option only if:
63
+
64
+
1. There are no side effects to calling this procedure on demand, multiple times, whenever Power Apps refreshes the control. When used with an **Items** property of a gallery or table, Power Apps calls the stored procedure whenever the system determines a refresh is needed. You can't control when the stored procedure is called.
65
+
2. The stored procedure returns less than the delegable limit (500/2000) of records. When a table or view is assigned to an **Items** property, Power Apps can control the paging and bring in 100 records at a time, when it needs it. Stored procedures are different and might be pageable through an argument to the stored procedure. But Power Apps can't bring in pages automatically like it can for tables and views. The author must configure pageability.
66
+
67
+
### Example
68
+
69
+
When you add a stored procedure, you might see more than one data source in your project.
70
+
71
+
:::image type="content" source="media/connection-azure-sqldatabase/sqlserver-datasources.png" alt-text="Screenshot that shows SQL data sources.":::
72
+
73
+
Prefix the stored procedure name with the name of connector associated with it. For example, _DataCardValue3_1.Text_ is from the _DataCard_ connector.
74
+
75
+
Label the values, for example using a number, as necessary since you're reading from a text value in Power Apps.
> To use a stored procedure in an **Item** property for a gallery or table, use the stored procedure name where you'd use the table name.
81
+
53
82
## Known issues
54
83
55
-
### SQL data sources no longer adds a "[dbo]" prefix to the data source name
84
+
### SQL data sources no longer add a `[dbo]` prefix to the data source name
85
+
86
+
The `[dbo]` prefix doesn't serve any practical purpose in Power Apps as data source names are automatically disambiguated. Existing data sources aren't affected by this change, but any newly added SQL data sources don't include the prefix.
56
87
57
-
The "[dbo]" prefix does not serve any practical purpose in Power Apps as datasource names are automatically disambiguated. Existing data sources won't be affected, but any newly added SQL data sources won't include the prefix. If you need to update a large number of formulas in one of your apps, the [Power Apps Source File Pack and Unpack Utility](https://powerapps.microsoft.com/blog/source-code-files-for-canvas-apps/) can be used to do a global search-and-replace.
88
+
If you need to update a large number of formulas in one of your apps, the [Power Apps Source File Pack and Unpack Utility](https://powerapps.microsoft.com/blog/source-code-files-for-canvas-apps/) can be used to do a global search-and-replace.
58
89
59
-
Starting in version 3.21054, we'll automatically update broken legacy name references to the new data source name after reading the data source.
90
+
> [!NOTE]
91
+
> Starting in version 3.21054, we'll automatically update broken legacy name references to the new data source name after reading the data source.
60
92
61
93
## Next steps
62
94
63
-
* Learn how to [show data from a data source](../add-gallery.md).
64
-
* Learn how to [view details and create or update records](../add-form.md).
65
-
* See other types of [data sources](../connections-list.md) to which you can connect.
66
-
*[Understand tables and records](../working-with-tables.md) with tabular data sources.
95
+
- Learn how to [show data from a data source](../add-gallery.md).
96
+
- Learn how to [view details and create or update records](../add-form.md).
97
+
- See other types of [data sources](../connections-list.md) to which you can connect.
98
+
-[Understand tables and records](../working-with-tables.md) with tabular data sources.
0 commit comments