Hello,
Can you please help me to how to convert below SQL Server code to FetchXML?
I want to create SQL server job by Deploying SSIS Package. Job will execute every day and i want to retain only last 30 days data from current date.
DELETE FROM TABLE_P WHERE CREATEDON < CAST(DATEADD(day, -30, GETDATE()) AS date)
*This post is locked for comments
Hi,
you can take a look below article. but you have to modify the date to suit your needs.
Hello, The table contains huge number of records (table name: exceptionlog table, it contains all audit data). Now i have to retain only last 30 days data and i have to remove all old audit data. so i have prepared above sql query to achieve this. Is there any other way to achieve this instead of sql query?
Hi Srinivas ,
Is there any specific reason you want to delete data using FetchXML ?
FetchXML used for data retrieval and not for deletion. I believe you are aware that there is OOB functionality called Bulk Deletion , you can define the condition and delete data as per your needs.
Check here -
docs.microsoft.com/.../delete-bulk-records
www.powerobjects.com/.../recurring-bulk-deletion-in-dynamics-crm-2011
crmtipoftheday.com/.../bulk-delete
If you want to delete data using code you may check below reference -
docs.microsoft.com/.../sample-execute-multiple-requests
docs.microsoft.com/.../sample-create-retrieve-update-delete-late-bound
Hi,
FetchXML does not support for delete. Furthermore, you shouldnt delete the records directly using SQL, this is unsupported.
To delete the record,
1. Construct your query to get all related records.
docs.microsoft.com/.../use-fetchxml-construct-query
2. Execute Delete request.
- docs.microsoft.com/.../sample-create-retrieve-update-delete-late-bound
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,240 Super User 2024 Season 2
Martin Dráb 230,149 Most Valuable Professional
nmaenpaa 101,156