Skip to content

Commit 077c866

Browse files
directly call stored procedures
1 parent 13dcec3 commit 077c866

File tree

5 files changed

+35
-23
lines changed

5 files changed

+35
-23
lines changed

powerapps-docs/maker/canvas-apps/connections/connection-azure-sqldatabase.md

Lines changed: 35 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -17,47 +17,59 @@ contributors:
1717
---
1818
# Connect to SQL Server from Power Apps
1919

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.
20+
Connect to SQL Server, in either Azure or an on-premises database.
2121

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.
24-
25-
## Prerequisites
26-
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).
22+
> [!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.
3724
3825
## Generate an app automatically
3926

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-
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.
4328

4429
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:
30+
2. Depending on how you want to create your app, from the home screen, select one of the following options:
4631
- To create a single-page gallery app with a responsive layout, choose either:
4732
- **Start with data** > **Connect to external data** > **From SQL**.
4833
- **Start with a page design** > **Gallery connected to external table** > **From SQL**.
4934
- 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.
51-
1. When you're done, select **Create app**.
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**.
37+
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.
40+
41+
![Preview flag to enable direct calls of stored procedures.](media/connection-azure-sqldatabase/previewflag-call-sp-direct.png "Preview flag to enable direct calls of stored procedures")
42+
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.
44+
45+
![Selecting tables, views, and stored procedures.](media/connection-azure-sqldatabase/tables-views-stored-proc-selector.png "Selecting tables, views, and stored procedures")
46+
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:
48+
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.
51+
52+
### Example
53+
When you add a stored procedure, you may see more than one data source in your project.
54+
55+
![Sql data sources.](media/connection-azure-sqldatabase/sqlserver-datasources.png "Sql data sources.")
56+
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.
58+
59+
![Calling stored procedures directly.](media/connection-azure-sqldatabase/calling-sp-directly.png "Calling stored procedures directly.")
60+
61+
* 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.
5262

5363
## Known issues
5464

5565
### SQL data sources no longer adds a "[dbo]" prefix to the data source name
5666

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.
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.
5868

5969
Starting in version 3.21054, we'll automatically update broken legacy name references to the new data source name after reading the data source.
6070

71+
72+
6173
## Next steps
6274

6375
* Learn how to [show data from a data source](../add-gallery.md).

0 commit comments

Comments
 (0)