Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics 365 | Integration, Dataverse...
Unanswered

How to delete D365 CE data from a Data Export Service Azure Synapse Database?

(0) ShareShare
ReportReport
Posted on by 1,589

I have a D365 CE environment with Data Export Services configured to sync to an Azure Synapse Database using the Append Only option. 

The append only option is key because it's creating a new row every time a record is updated. 

Keep in mind that the append only option is a vendor requirement for a specific integration we have so we can't change it. 

To keep things clean, I need to delete all rows that are older than 48 hours. This is needed to speed up query times and also conform to cost requirements. 

I tried to use the query below, but since the tables appear in the Synapse replica as "External Table" I receive an error when I try to delete them also shown below. 

CREATE PROCEDURE DeleteStaleData
AS 
BEGIN  
DELETE FROM [dbo].[cpp_job] 
 WHERE [SinkModifiedOn] >= DATEADD(HOUR, -48, GETDATE())
 END  

Msg 46519, Level 16, State 17, Procedure DeleteStaleData, Line 11 [Batch Start Line 0

DML Operations are not supported with external tables.

My goal is to set up some kind of automated job that deletes any rows in a table whose SinkModifiedOn is  older than 48 hours

I assume that they are external tables because they are presenting the contents of the CSV files located in the corresponding storage account.

I need to create something that automatically deletes all rows from that synapse environment that are older than 48 hours, basically implementing the code shown below and I need it to run once per day. 

DELETE FROM [dbo].[cpp_job] 
 WHERE [SinkModifiedOn] >= DATEADD(HOUR, -48, GETDATE())

What do I need to create exactly do to this? 

Do I need to create something that deletes the CSV files located in the corresponding storage account? 

How do I determine ensure whatever "thing" I create to do the deletion, is actually deleting everything older than 48 hours?

Any help of recommendations would be greatly appreciated.  

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Jonas ”Jones” Melgaard – Community Spotlight

We are honored to recognize Jonas "Jones" Melgaard as our April 2025…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 294,430 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 233,043 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,158 Moderator

Leaderboard

Product updates

Dynamics 365 release plans