Sync Salesforce leads to SQL Server on schedule
CRMMarketingRecipe ToolsWorkatoDatabase
What it does
When new or updated leads appear in Salesforce on a specified interval, this automation replicates them to SQL Server in batches. It logs the replication outcome so the team knows which records synced and which failed.
Who it's for
Data and analytics teams who need Salesforce leads in SQL Server for reporting and analysis.
How teams use this
Replicate leads for daily reporting
Run the sync each morning so the analytics team has fresh Salesforce lead data in SQL Server for dashboards and reports. The batch approach keeps the load predictable.
Sync leads to a data warehouse
Point the automation at a different SQL Server database or schema so leads flow into a centralized warehouse instead of a local instance. The replication logic stays the same.
Add lead scoring to the sync
Include a condition in the schema function to filter or enrich leads based on a scoring field so only qualified leads are replicated to SQL Server. Set the filter before the upsert step.
Alert on replication failures
Add a notification step after the error log so the team gets a message when a batch fails to sync. Check the log outcome and only send the alert if the status is failure.
How it works
- Check for new or updated leads. On a scheduled interval, Salesforce checks for leads that are new or have changed since the last batch run.
- Prepare variables for the sync. Set up variables for the start time, source system, table name, batch size, and log ID so the replication can track its progress.
- Apply schema and replicate leads. Call the schema function to map Salesforce fields, then upsert the batch of leads into the SQL Server Salesforce.Lead table.
- Log the replication result. Execute the replication log stored procedure in SQL Server to record whether the batch succeeded or failed, with row counts and timestamps.