Set up a pre-sync script

Aparna Manoharan 20 Reputation points
2024-09-16T13:37:40.8+00:00

We are using Azure Data Sync to synchronise two databases. Sync groups are set up to run every 30 mins automatically.

How to set up a pre-sync script and post-sync script ?

Azure SQL Database
{count} votes

1 answer

Sort by: Most helpful
  1. Sina Salam 12,011 Reputation points
    2024-09-16T16:56:07.63+00:00

    Hello Aparna Manoharan,

    Welcome to the Microsoft Q&A and thank you for posting your questions here.

    I understand that you are keen to know how to implement pre-sync script and post-sync script in your Azure Data Sync.

    After you must have done necessary configurations in your Azure Portal. The Pre-Sync will look similar to the below to run before the synchronization process starts:

           CREATE PROCEDURE PreSyncProcedure
           AS
           BEGIN
               -- Your pre-sync logic here
               ALTER TABLE [YourTable] NOCHECK CONSTRAINT ALL;
           END
    

    Your Post-Sync Scripts will also look similar to the below to run after the synchronization process completes.

           CREATE PROCEDURE PostSyncProcedure
           AS
           BEGIN
               -- Your post-sync logic here
               ALTER TABLE [YourTable] CHECK CONSTRAINT ALL;
               UPDATE [YourTable] SET LastSync = GETDATE();
           END
    

    For best practices on how to set up and steps to follow can be view in this link:

    I hope this is helpful! Do not hesitate to let me know if you have any other questions.

    Please don't forget to close up the thread here by upvoting and accept it as an answer if it is helpful.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.