in Education by
I am trying to use change tracking to copy data incrementally from a SQL Server to an Azure SQL Database. I followed the tutorial on Microsoft Azure documentation but I ran into some problems when implementing this for a large number of tables. In the source part of the copy activity I can use a query that gives me a change table of all the records that are updated, inserted or deleted since the last change tracking version. This table will look something like PersonID Age Name SYS_CHANGE_OPERATION --------------------------------------------- 1 12 John U 2 15 James U 3 NULL NULL D 4 25 Jane I with PersonID being the primary key for this table. The problem is that the copy activity can only append the data to the Azure SQL Database so when a record gets updated it gives an error because of a duplicate primary key. I can deal with this problem by letting the copy activity use a stored procedure that merges the data into the table on the Azure SQL Database, but the problem is that I have a large number of tables. I would like the pre-copy script to delete the deleted and updated records on the Azure SQL Database, but I can't figure out how to do this. Do I need to create separate stored procedures and corresponding table types for each table that I want to copy or is there a way for the pre-copy script to delete records based on the change tracking table? Select the correct answer from above options

1 Answer

0 votes
by
 
Best answer
Before the Copy Activity, use a LookUp activity and that, you should be able to query the database which will provide you the deleted & updated PersonIDs, mostly in all the field and seperated by comma. Try this pre-copy script: delete from TableName where PersonID in (@{activity('MyLookUp').output.firstRow.PersonIDs}) With this, you should be able to delete or update rows even before inserting the new ones. You can refer to this official document for more help: https://docs.microsoft.com/en-us/azure/data-factory/control-flow-lookup-activity

Related questions

0 votes
    I have one SQL job which actually checks fragmentation % in DB of all the indexes and Rebuilds indexes if required. ... new to Azure. Select the correct answer from above options...
asked Feb 8, 2022 in Education by JackTerrance
0 votes
    I have one SQL job which actually checks fragmentation % in DB of all the indexes and Rebuilds indexes if required. ... new to Azure. Select the correct answer from above options...
asked Feb 5, 2022 in Education by JackTerrance
0 votes
    I've a lookup activity with gets value from a container within a blob. I have a foreach activity which is ... : data.speed> 500 Select the correct answer from above options...
asked Feb 4, 2022 in Education by JackTerrance
0 votes
    We have a few databases in Pricing Tier: Basic, S0... like below picture: These databases were created before a ... the Azure portal. Select the correct answer from above options...
asked Feb 8, 2022 in Education by JackTerrance
0 votes
    I have a setup in Azure with a bunch of resources combined in a resource group. I want my services to be ... it not impact anything? Select the correct answer from above options...
asked Feb 8, 2022 in Education by JackTerrance
0 votes
    I have tried and tried, and can not get linked. I can connect to the server using SSMS, but can not link to ... = '[password]' GO Select the correct answer from above options...
asked Feb 8, 2022 in Education by JackTerrance
0 votes
    I recently upgraded from Entities Framework 5 to Entities Framework 6 Alpha 2 and I am getting the following ... Any suggestions? Select the correct answer from above options...
asked Jan 30, 2022 in Education by JackTerrance
0 votes
    I had to add some ugly links in my website that looks like: "/page/?utm_source=value&utm_source= ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 20, 2022 in Education by JackTerrance
0 votes
    I have 100 records in source table, but I want to load 1, 5,10,15,20…..100 into target table. How can I do this? Explain in detailed mapping flow....
asked Mar 28, 2021 in Technology by JackTerrance
0 votes
    What is not true in context of HTML tag ? O Table cell changes its width automatically based on content O We can ... table border is o Select the correct answer from above options...
asked Nov 30, 2021 in Education by JackTerrance
0 votes
    How can I remove this file from the repo without deleting my local copy of the file?...
asked Jan 8, 2021 in Technology by JackTerrance
0 votes
    I have one script and many websites, because they are on the same server how can I execute same ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 13, 2022 in Education by JackTerrance
0 votes
    I have one script and many websites, because they are on the same server how can I execute same ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 13, 2022 in Education by JackTerrance
0 votes
    I had someting like this in my code (.Net 2.0, MS SQL) SqlConnection connection = new SqlConnection ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 15, 2022 in Education by JackTerrance
...