SharePoint to SQL Sync
When a SharePoint list item is modified, update the corresponding row in SQL to keep the two systems in sync. Demonstrates cross-system data synchronization.
Provided as-is, without warranty of any kind. Review and test each pattern in a non-production environment before deploying it to live automations. See our Terms.
Overview
FlowLibs - SharePoint to SQL Sync is an intermediate-level integration flow that demonstrates cross-system data synchronization between SharePoint Online and SQL Server. When a SharePoint list item is modified, the flow retrieves the full item details, constructs a dynamic SQL UPDATE statement, executes it against the target SQL table, and — if no matching row exists — automatically inserts a new row. This upsert pattern ensures both systems stay in sync without manual intervention.
Use Case
Organizations often maintain data in both SharePoint (for business user collaboration) and SQL Server (for reporting, BI, or application backends). This flow bridges the gap by automatically propagating changes from SharePoint to SQL in near-real-time (1-minute polling). Common scenarios include: keeping a reporting database in sync with a SharePoint task list, mirroring project metadata from SharePoint to a SQL data warehouse, and maintaining a single source of truth across hybrid data architectures.
The flow is ideal for teams that:
- Keeping a reporting database in sync with a SharePoint task list
- Mirroring project metadata from SharePoint to a SQL data warehouse
- Maintaining a single source of truth across hybrid data architectures
Flow Architecture
When an Existing Item Is Modified
SharePoint - When an existing item is modifiedPolls the configured SharePoint list every 1 minute for modified items.
Init varSqlServerName
Initialize Variable (string)Hydrates SQL Server hostname from flowlibs_SqlServerName env var.
Init varSqlDatabaseName
Initialize Variable (string)Hydrates SQL database name from flowlibs_SqlDatabaseName env var.
Init varSqlTableName
Initialize Variable (string)Hydrates SQL table name from flowlibs_SPtoSQLSyncTableName env var.
Init varSharePointSiteUrl
Initialize Variable (string)Hydrates SharePoint site URL from flowlibs_SharePointSiteURL env var.
Init varSPListId
Initialize Variable (string)Hydrates SharePoint list GUID from flowlibs_SPtoSQLSyncListID env var. Note: steps 2-6 run in parallel for performance.
Get Modified Item Details
SharePoint - GetItemRetrieves full item details (Title, Modified date, Editor, Version) by ID from the trigger.
Compose Update SQL
ComposeBuilds a dynamic UPDATE statement mapping SP fields to SQL columns (Title, ModifiedDate, ModifiedBy, SPItemVersion) with proper N-string escaping.
Execute SQL Update
SQL Server - ExecutePassThroughNativeQuery_V2Executes the UPDATE statement against the target SQL table.
Environment Variables
| Schema name | Type | Default | Description |
|---|---|---|---|
| flowlibs_SharePointSiteURL | String | https://your-tenant.sharepoint.com | Root SharePoint site URL that hosts the source list. |
| flowlibs_SPtoSQLSyncListID | String | <configure> | GUID of the SharePoint list to monitor for modifications. Replace with the real list ID from your SharePoint list settings page. |
| flowlibs_SqlServerName | String | your-server.database.windows.net | SQL Server hostname (Azure SQL FQDN or on-prem server name). |
| flowlibs_SqlDatabaseName | String | FlowLibsDemoDB | Target database name. |
| flowlibs_SPtoSQLSyncTableName | String | [dbo].[SPSyncItems] | Fully qualified target SQL table for sync (schema-qualified, bracketed). |
Connectors & Connections
| Connector | API name | Actions used |
|---|---|---|
| SharePoint Online | shared_sharepointonline | OnUpdatedItems (trigger) GetItem |
| SQL Server | shared_sql | ExecutePassThroughNativeQuery_V2 (Used for UPDATE, SELECT COUNT, and INSERT statements) |
Note — All connections are referenced as solution connection references; the flow is portable between environments as long as a connection is mapped at import time.
Customization Guide
Almost every realistic variant of this flow can be implemented by changing environment variable values. A few cases require small edits inside the flow definition — those are called out explicitly below.
- Deploy in your environment
- Import the solution into your target environment, update the 5 environment variable values to match your tenant (SP site URL, list GUID, SQL server, database, table name), authorize the SharePoint and SQL Server connections, then turn on the flow.
- Create the target SQL table
- Run: CREATE TABLE [dbo].[SPSyncItems] ( SPItemId INT PRIMARY KEY, Title NVARCHAR(255), ModifiedDate DATETIME2, ModifiedBy NVARCHAR(255), SPItemVersion NVARCHAR(50) ); — adjust the table name to match flowlibs_SPtoSQLSyncTableName.
- Sync additional SharePoint fields
- Edit the 'Compose Update SQL' and 'Compose Insert SQL' actions to include additional SharePoint columns. Reference them using outputs('Get_Modified_Item_Details')?['body/{InternalFieldName}']. Add a matching column to the target SQL table.
- Tune polling cadence
- The SharePoint 'When an existing item is modified' trigger polls every 1 minute by default. Adjust the trigger's recurrence to lower SharePoint API pressure on large lists, or keep at 1 minute for near-real-time sync.
Key Expressions
The flow is intentionally light on Power Fx / WDL gymnastics — the heaviest expressions are the branch-name concatenation and the approval outcome check. They are listed below in the order they appear in the flow.
EXPR.01SQL string escaping
Escapes single quotes for safe SQL string interpolation inside the Compose Update/Insert actions.
EXPR.02Dynamic SQL construction
Builds the full UPDATE statement from the env-var-configured table name so the same flow works against any target table.
EXPR.03Row existence check
Extracts the COUNT result from the SQL response for the If-no-matching-row branch.
EXPR.04Upsert pattern note
This avoids race conditions and is idempotent — re-running the flow against the same item is safe.
Comments
Sign in to join the conversation.
Sign inNo comments yet. Be the first to share your experience with this flow.