How to perform data sync in Azure to sync data between 2 tables in the azure cloud datbases

Eshwar Nakkala 106 Reputation points
2021-01-29T07:26:07.793+00:00

Hi Team,

I have 2 tables "TB1,TB2" in the azure sql databases named "test_db1" and "test_db2". I have a requirement need to copy/sync data bidirectionally in the 2 tables "TB1,TB2" from 2 different databases

For the same requirement have achieved with the data sync option in azure data factory but I need to do it in other ways also.

Kindly assist me to achieve this requirement.

Regards,
Eshwar Nakkala.

Azure SQL Database
0 comments No comments
{count} votes

Accepted answer
  1. Anurag Sharma 17,631 Reputation points
    2021-01-29T12:09:36.923+00:00

    Hi @Eshwar Nakkala , welcome to Microsoft Q&A forum.

    As mentioned, both the tables are in same database, so easiest approach would be to write a merge statement like below.

    MERGE tableA AS A  
    USING tableB AS B  
    ON  A.ID = B.ID   
    WHEN MATCHED THEN  
      --update statements like UPDATE SET A.Name = B.Name  
    WHEN NOT MATCHED THEN  
    INSERT (UserName)  
    --Insert statement here  
    

    You can change the order of the tables to sync in other direction.

    Now this query you can run manually as well as you can automate it easily as mentioned in below article:
    https://www.2azure.nl/2020/09/17/azure-automation-run-sql-command-on-azure-sql-manual/

    Please let me know if this helps or else we can discuss further.

    ----------

    If answer helps, you can mark it as 'Accept Answer'


0 additional answers

Sort by: Most 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.