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,66 +15,86 @@ contributors:
15
15
- mduelae
16
16
- lancedmicrosoft
17
17
---
18
+
18
19
# Connect to SQL Server from Power Apps
19
20
20
-
Connect to SQL Server, in either Azure or an on-premises database.
21
+
You can connect to SQL Server in either Azure or an on-premises database.
21
22
22
23
> [!NOTE]
23
-
> Newly created SQL data sources are no longer prefixed with "[dbo]" as they have been in previous versions of Power Apps. For more information, see the [common issues and resolutions](/troubleshoot/power-platform/power-apps/common-issues-and-resolutions) page.
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).
24
27
25
28
## Generate an app automatically
26
29
27
-
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 to know more.
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.
28
31
29
32
1. Sign in to [Power Apps](https://make.powerapps.com?utm_source=padocs&utm_medium=linkinadoc&utm_campaign=referralsfromdoc).
30
-
2. 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:
31
34
- To create a single-page gallery app with a responsive layout, choose either:
32
-
-**Start with data** > **Connect to external data** > **From SQL**.
33
-
-**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**.
34
37
- To create a three screen mobile app, select **Start with an app template** > **From SQL**.
35
-
3. 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.
36
-
4. When you're done, select **Create app**.
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.
42
+
1. When you're done, select **Create app**.
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.
37
51
38
-
## Call stored procedures directly in Power Fx (Preview)
39
-
You can directly call SQL Server stored procedures from Power Fx. First you must turn on the SQL Server stored procedure preview switch. Navigate to Settings > Upcoming features > Preview. Search for "stored procedures" and turn on the preview switch as show in the image.
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.":::
40
53
41
-

54
+
When you add a SQL Server connection to your app, you can now add tables and views or stored procedures.
42
55
43
-
With this feature turned you have the ability to add table, views, and stored procedures to your application. When you add a SQL Server connection to your app, you're presented a list of tables and views and also a list of stored procedures.
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.":::
44
57
45
-

58
+
If you don't immediately see your stored procedure, it's faster to search for it.
46
59
47
-
If you don't immediately see your stored procedure, it's faster to search for it. Notice that once you select a stored procedure a child node appears and you have the ability to 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. Only enable this option if:
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.
48
61
49
-
1. There are no side effects to calling this procedure on demand, multiple times, whenever Power Apps decides it needs to refresh 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 it's called.
50
-
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 aren't pageable in the same way. They may be pageable via an argument to the stored procedure but you, as the author, are responsible for ensuring such behavior. Power Apps can't do this automatically like it can for tables and views.
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.
51
66
52
67
### Example
53
-
When you add a stored procedure, you may see more than one data source in your project.
54
68
55
-

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.
56
74
57
-
* Access the stored procedure by prefixing the stored procedure name with the name of connector associated with it. Be sure to cast the values (e.g., to a number) as necessary as you a reading from a text value in Power Apps.
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 simply use the stored procedure name in the same place where you would a table name.
79
+
> [!TIP]
80
+
> 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.
62
81
63
82
## Known issues
64
83
65
-
### 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
66
85
67
-
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, 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.
68
-
69
-
Starting in version 3.21054, we'll automatically update broken legacy name references to the new data source name after reading the data source.
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.
70
87
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.
71
89
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.
72
92
73
93
## Next steps
74
94
75
-
* Learn how to [show data from a data source](../add-gallery.md).
76
-
* Learn how to [view details and create or update records](../add-form.md).
77
-
* See other types of [data sources](../connections-list.md) to which you can connect.
78
-
*[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