SQL Server

SQL Server

Microsoft SQL Server is a relational database management system developed by Microsoft. Connect to SQL Server to manage data. You can perform various actions such as create, update, get, and delete on rows in a table.

This connector is available in the following products and regions:

Service Class Regions
Logic Apps Standard All Logic Apps regions except the following:
     -   Azure Government regions
     -   Azure China regions
Flow Standard All Flow regions
PowerApps Standard All PowerApps regions

To use this connector in PowerApps, learn more here.

Known issues and limitations

The followings are some of the known limitations of using SQL connector

  1. Stored Procedures cannot be invoked from PowerApps.
    • One workaround is to create a Flow and invoke the Flow from PowerApps.
  2. Insert and update to a table does not work if you have a SQL server side Trigger defined on the table. To workaround this issue, you can do either of the following:
    • Use a Stored Procedure or Native Query
    • Remove the Trigger from your SQL table
  3. When invoking a Stored Procedure on an on-premises SQL server, we have the following limitations:
    • Output values for OUTPUT parameters are not returned. You can still specify input values for OUTPUT parameters.
    • Return value is not available.
    • Only the first result set is returned.
    • Dynamics schemas are not supported for result sets.
  4. A Primary Key is required for the following operations:
    • GetItem
    • UpdateItem
    • DeleteItem
  5. When invoking triggers, we have the following limitations:
    • A ROWVERSION column is required for OnUpdatedItems
    • An IDENTITY column is required for OnNewItems
  6. The response size limit is 8MB through on-premises SQL server.
  7. SQL native query is not supported for on-premises SQL server.
  8. The following data types cannot be used as query option predicates:
    • date
    • datetime
    • datetime2
    • smalldatetime

PowerApps data type mappings

SQL Server PowerApps
bigint, decimal, int, money, numeric, smallint, smallmoney, tinyint, float, real Number
char, nchar, varchar, nvarchar, text, ntext Text
bit Boolean
date, datetime/datetime2/smalldatetime, datetimeoffset, time DateTime
uniqueidentifier Guid

Note

If a SQL Server data type is not listed in the table above, it is not supported. Examples of unsupported SQL Server data types include: binary(), varbinary(), image, cursor, rowversion, hierarchyid, sql_variant xml, Spatial Geometry Types, Spatial Geography Types, and table.

PowerApps delegable functions and operations for SQL Server

These PowerApps operations, for a given data type, may be delegated to SQL Server for processing (rather than processing locally within PowerApps).

Operation/Function Number Text Boolean DateTime Guid
Filter Yes Yes Yes No [1] Yes
Sort Yes Yes Yes Yes -
SortByColumns Yes Yes Yes Yes -
Search No Yes No No -
Lookup Yes Yes Yes Yes Yes
=, <> Yes Yes Yes No Yes
<, <=, >, >= Yes No No No -
in (substring) - Yes [2] - - -
+ Yes - - No -
- Yes - - No -
* Yes - - No -
/ Yes - - No -
StartsWith - Yes [3] - - -
EndsWith - Yes [4] - - -
IsBlank No [5] No [5] No [5] No [5] No [5]
Len (length) - Yes [6] - - -
Sum Yes - - - -
Average Yes - - - -
Min Yes - - No -
Max Yes - - No -

Note

Expressions joined with And, Or, and Not are delegable to SQL Server.

  1. Direct date filters do not work for SQL Server. However, you can create a calculated column that will work. For instance, ALTER TABLE myTable ADD DateAsInt AS (YEAR([date]) * 10000 + MONTH([date]) * 100 + DAY([date])) and then filter on the calculated number column.
  2. The 'in' (substring) operator. Supported for ("string value" in <column>), but not for (<column> in "string value").
  3. StartsWith. Supported for (StartsWith(<column>, "string value")), but not for (StartsWith("string value", <column>)).
  4. EndsWith. Supported for (EndsWith(<column>, "string value")) but not for (EndsWith("string value", <column>)). If a char(10) column has a value of "hello", EndsWith(<column>, "llo") will return false, and that's by design. A char(10) column has 10 characters.
  5. An expression such as Filter('[dbo].[MyOrders]', !IsBlank(CustomerId)) won't delegate to the server. However, this is semantically close to Filter('[dbo].[MyOrders]', CustomerId <> Blank()), which does delegate to the server. These expressions differ in that the second expression won't treat the empty string ("") as Empty. These expressions aren't equivalent, but the latter might work for your purposes. You can’t use this method for the Guid data type.
  6. Len. PowerApps delegates the Len function, but it might not work as you expect. A char(10) column with value "hello" will always have, in SQL Server, a length of 10. But PowerApps will treat that string as having a length of 5, which could cause discrepancies and confusion. You shouldn't use char/nchar on the server; use varchar/nvarchar instead.

Throttling Limits

Name Calls Renewal Period
API calls per connection 800 10 seconds

Creating a connection

To connect your account, you will need the following information:

SQL server name
string
SQL server name
SQL database name
string
SQL database name
Authentication Type
string
Authentication type to connect to your database
Username
securestring
Username credential
Password
securestring
Password credential
SQL Connection String
securestring
SQL Connection String
Gateway
gatewaySetting

Actions

Delete row

This operation deletes a row from a table.

Required Parameters

Table name
string
Name of table
Row id
string
Unique identifier of the row to delete

Execute a SQL query

Execute a SQL query

Required Parameters

Query
dynamic
query body

Returns

The outputs of this operation are dynamic.

Execute stored procedure

This operation runs a stored procedure.

Required Parameters

Procedure name
string
Name of stored procedure
Parameters list
dynamic
Input parameters to the stored procedure

Returns

The outputs of this operation are dynamic.

Get row

This operation gets a row from a table.

Required Parameters

Table name
string
Name of SQL table
Row id
string
Unique identifier of the row to retrieve

Returns

The outputs of this operation are dynamic.

Get rows

This operation gets rows from a table.

Required Parameters

Table name
string
Name of SQL table

Optional Parameters

Aggregation transformation
string
A sequence of OData aggregation transformations
Filter Query
string
An ODATA filter query to restrict the entries returned (e.g. stringColumn eq 'string' OR numberColumn lt 123).
Order By
string
An ODATA orderBy query for specifying the order of entries.
Skip Count
integer
The number of entries to skip (default = 0).
Top Count
integer
Total number of entries to retrieve (default = all).
Select Query
string
Specific fields to retrieve from entries (default = all).

Returns

The outputs of this operation are dynamic.

Get tables

This operation gets tables from a database.

Required Parameters

Table name
string
Name of table
Row id
string
Unique identifier of the row to delete

Returns

Body
TablesList

Represents a list of tables.

Insert row

This operation inserts a new row into a table.

Required Parameters

Table name
string
Name of table
Row
dynamic
Row to insert into the specified table

Returns

The outputs of this operation are dynamic.

Transform data using Power Query

Transform data using Power Query

Optional Parameters

query
mquery
Query Text

Returns

The outputs of this operation are dynamic.

Update row

This operation updates an existing row in a table.

Required Parameters

Table name
string
Name of table
Row id
string
Unique identifier of the row to update
Row
dynamic
Row with updated values

Returns

The outputs of this operation are dynamic.

Triggers

When an item is created

Triggers a flow when an item is created in Sql

Required Parameters

Table name
string
Name of Sql table

Optional Parameters

Filter Query
string
An ODATA filter query to restrict the entries returned (e.g. stringColumn eq 'string' OR numberColumn lt 123).
Top Count
integer
Total number of entries to retrieve (default = all).
Order By
string
An ODATA orderBy query for specifying the order of entries.
Select Query
string
Specific fields to retrieve from entries (default = all).

Returns

The outputs of this operation are dynamic.

When an item is modified

Triggers a flow when an item is modified in Sql

Required Parameters

Table name
string
Name of Sql table

Optional Parameters

Filter Query
string
An ODATA filter query to restrict the entries returned (e.g. stringColumn eq 'string' OR numberColumn lt 123).
Top Count
integer
Total number of entries to retrieve (default = all).
Order By
string
An ODATA orderBy query for specifying the order of entries.
Select Query
string
Specific fields to retrieve from entries (default = all).

Returns

The outputs of this operation are dynamic.

Definitions

Table

Represents a table.

DisplayName
string
The display name of the table.
DynamicProperties
object
Additional table properties provided by the connector to the clients.
Name
string
The name of the table. The name is used at runtime.

TablesList

Represents a list of tables.

value
array of Table
List of Tables