{"id":794,"date":"2020-04-25T21:41:12","date_gmt":"2020-04-26T02:41:12","guid":{"rendered":"http:\/\/www.sqlfreelancer.com\/blog\/?p=794"},"modified":"2023-01-10T09:50:26","modified_gmt":"2023-01-10T15:50:26","slug":"insert-update-a-sql-server-table-using-merge-join-in-ssis","status":"publish","type":"post","link":"https:\/\/www.sqlfreelancer.com\/blog\/insert-update-a-sql-server-table-using-merge-join-in-ssis\/","title":{"rendered":"SSIS Series: Insert\/Update a SQL Server table using Merge Join in SSIS"},"content":{"rendered":"\r\n<p>I was asked a question awhile back on the easiest way to do an incremental load from one SQL Server table into another SQL Server table. This is common in data warehouses or reporting tables as you wouldn\u2019t want to truncate a large table and perform a full insert. Instead, you would want to only copy the changes from the source to the destination. This could be an insert or an update. The easiest way, IMO, is SSIS. Let\u2019s take a look.<\/p>\r\n\r\n\r\n\r\n<p>Here\u2019s how my environment is setup. I have two databases appropriately named Transactional (for transactional data) and Reporting (for static report data). Two tables, Source and Destination.<\/p>\r\n\r\n\r\n\r\n<div class=\"wp-block-image\">\r\n<figure class=\"aligncenter size-large\"><a href=\"https:\/\/www.sqlfreelancer.com\/blog\/wp-content\/uploads\/2020\/04\/Merge-Join-1.png\"><img loading=\"lazy\" decoding=\"async\" width=\"381\" height=\"643\" class=\"wp-image-797\" src=\"https:\/\/www.sqlfreelancer.com\/blog\/wp-content\/uploads\/2020\/04\/Merge-Join-1.png\" alt=\"\" srcset=\"https:\/\/www.sqlfreelancer.com\/blog\/wp-content\/uploads\/2020\/04\/Merge-Join-1.png 381w, https:\/\/www.sqlfreelancer.com\/blog\/wp-content\/uploads\/2020\/04\/Merge-Join-1-178x300.png 178w\" sizes=\"auto, (max-width: 381px) 100vw, 381px\" \/><\/a><\/figure>\r\n<\/div>\r\n\r\n\r\n\r\n<p>I also added some dummy data as you see below. I\u2019ve highlighted what is different and will need to be changed in the destination table.<\/p>\r\n\r\n\r\n\r\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.sqlfreelancer.com\/blog\/wp-content\/uploads\/2020\/04\/Merge-Join-2.png\"><img loading=\"lazy\" decoding=\"async\" width=\"714\" height=\"469\" class=\"wp-image-798\" src=\"https:\/\/www.sqlfreelancer.com\/blog\/wp-content\/uploads\/2020\/04\/Merge-Join-2.png\" alt=\"\" srcset=\"https:\/\/www.sqlfreelancer.com\/blog\/wp-content\/uploads\/2020\/04\/Merge-Join-2.png 714w, https:\/\/www.sqlfreelancer.com\/blog\/wp-content\/uploads\/2020\/04\/Merge-Join-2-300x197.png 300w\" sizes=\"auto, (max-width: 714px) 100vw, 714px\" \/><\/a><\/figure>\r\n\r\n\r\n\r\n<p>Let\u2019s open SSIS and create a new SSIS project. <br \/>Drag and drop a Data Flow task into the design window, right click, Edit:<\/p>\r\n\r\n\r\n\r\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.sqlfreelancer.com\/blog\/wp-content\/uploads\/2020\/04\/Merge-Join-3.png\"><img loading=\"lazy\" decoding=\"async\" width=\"850\" height=\"649\" class=\"wp-image-799\" src=\"https:\/\/www.sqlfreelancer.com\/blog\/wp-content\/uploads\/2020\/04\/Merge-Join-3.png\" alt=\"\" srcset=\"https:\/\/www.sqlfreelancer.com\/blog\/wp-content\/uploads\/2020\/04\/Merge-Join-3.png 850w, https:\/\/www.sqlfreelancer.com\/blog\/wp-content\/uploads\/2020\/04\/Merge-Join-3-300x229.png 300w, https:\/\/www.sqlfreelancer.com\/blog\/wp-content\/uploads\/2020\/04\/Merge-Join-3-768x586.png 768w\" sizes=\"auto, (max-width: 850px) 100vw, 850px\" \/><\/a><\/figure>\r\n\r\n\r\n\r\n<p>Next, drag and drop two OLE DB source components into the design window. I\u2019m going to rename mine Source and Destination to match my table names.<\/p>\r\n\r\n\r\n\r\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.sqlfreelancer.com\/blog\/wp-content\/uploads\/2020\/04\/Merge-Join-4.png\"><img loading=\"lazy\" decoding=\"async\" width=\"830\" height=\"811\" class=\"wp-image-800\" src=\"https:\/\/www.sqlfreelancer.com\/blog\/wp-content\/uploads\/2020\/04\/Merge-Join-4.png\" alt=\"\" srcset=\"https:\/\/www.sqlfreelancer.com\/blog\/wp-content\/uploads\/2020\/04\/Merge-Join-4.png 830w, https:\/\/www.sqlfreelancer.com\/blog\/wp-content\/uploads\/2020\/04\/Merge-Join-4-300x293.png 300w, https:\/\/www.sqlfreelancer.com\/blog\/wp-content\/uploads\/2020\/04\/Merge-Join-4-768x750.png 768w\" sizes=\"auto, (max-width: 830px) 100vw, 830px\" \/><\/a><\/figure>\r\n\r\n\r\n\r\n<p>Configure the two OLE DB sources to match the source table and the destination table. Below is a screenshot of my source connection manager.<\/p>\r\n\r\n\r\n\r\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.sqlfreelancer.com\/blog\/wp-content\/uploads\/2020\/04\/Merge-Join-5.png\"><img loading=\"lazy\" decoding=\"async\" width=\"723\" height=\"464\" class=\"wp-image-801\" src=\"https:\/\/www.sqlfreelancer.com\/blog\/wp-content\/uploads\/2020\/04\/Merge-Join-5.png\" alt=\"\" srcset=\"https:\/\/www.sqlfreelancer.com\/blog\/wp-content\/uploads\/2020\/04\/Merge-Join-5.png 723w, https:\/\/www.sqlfreelancer.com\/blog\/wp-content\/uploads\/2020\/04\/Merge-Join-5-300x193.png 300w\" sizes=\"auto, (max-width: 723px) 100vw, 723px\" \/><\/a><\/figure>\r\n\r\n\r\n\r\n<p>Once your connection managers are configured let\u2019s drag and drop two Sort components below each OLE DB Source and connect them to each source. We will be using a merge join next and the merge join component needs to have data sorted in ASC or DESC order. I always choose to sort on the Primary Key for each table.<\/p>\r\n\r\n\r\n\r\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.sqlfreelancer.com\/blog\/wp-content\/uploads\/2020\/04\/Merge-Join-6.png\"><img loading=\"lazy\" decoding=\"async\" width=\"848\" height=\"533\" class=\"wp-image-802\" src=\"https:\/\/www.sqlfreelancer.com\/blog\/wp-content\/uploads\/2020\/04\/Merge-Join-6.png\" alt=\"\" srcset=\"https:\/\/www.sqlfreelancer.com\/blog\/wp-content\/uploads\/2020\/04\/Merge-Join-6.png 848w, https:\/\/www.sqlfreelancer.com\/blog\/wp-content\/uploads\/2020\/04\/Merge-Join-6-300x189.png 300w, https:\/\/www.sqlfreelancer.com\/blog\/wp-content\/uploads\/2020\/04\/Merge-Join-6-768x483.png 768w\" sizes=\"auto, (max-width: 848px) 100vw, 848px\" \/><\/a><\/figure>\r\n\r\n\r\n\r\n<p>In my example, I\u2019ll choose to sort on my primary key, ID.<\/p>\r\n\r\n\r\n\r\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.sqlfreelancer.com\/blog\/wp-content\/uploads\/2020\/04\/Merge-Join-7.png\"><img loading=\"lazy\" decoding=\"async\" width=\"663\" height=\"712\" class=\"wp-image-803\" src=\"https:\/\/www.sqlfreelancer.com\/blog\/wp-content\/uploads\/2020\/04\/Merge-Join-7.png\" alt=\"\" srcset=\"https:\/\/www.sqlfreelancer.com\/blog\/wp-content\/uploads\/2020\/04\/Merge-Join-7.png 663w, https:\/\/www.sqlfreelancer.com\/blog\/wp-content\/uploads\/2020\/04\/Merge-Join-7-279x300.png 279w\" sizes=\"auto, (max-width: 663px) 100vw, 663px\" \/><\/a><\/figure>\r\n\r\n\r\n\r\n<p>Next, drag the Merge Join transformation into the Design window and drag the data path from the Sort component to the Merge Join. When you attach the arrow to the transformation, the Input Output Selection dialog box appears, displaying two options: the Output drop-down list and the Input drop-down list. The Output drop-down list defaults to Source Output, which is what we want. From the Input drop-down list, select Merge Join Left Input, as shown below. We\u2019ll use the other option, Merge Join Right Input, for the other connection.<\/p>\r\n\r\n\r\n\r\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.sqlfreelancer.com\/blog\/wp-content\/uploads\/2020\/04\/Merge-Join-8.png\"><img loading=\"lazy\" decoding=\"async\" width=\"823\" height=\"851\" class=\"wp-image-804\" src=\"https:\/\/www.sqlfreelancer.com\/blog\/wp-content\/uploads\/2020\/04\/Merge-Join-8.png\" alt=\"\" srcset=\"https:\/\/www.sqlfreelancer.com\/blog\/wp-content\/uploads\/2020\/04\/Merge-Join-8.png 823w, https:\/\/www.sqlfreelancer.com\/blog\/wp-content\/uploads\/2020\/04\/Merge-Join-8-290x300.png 290w, https:\/\/www.sqlfreelancer.com\/blog\/wp-content\/uploads\/2020\/04\/Merge-Join-8-768x794.png 768w\" sizes=\"auto, (max-width: 823px) 100vw, 823px\" \/><\/a><\/figure>\r\n\r\n\r\n\r\n<p>Next, connect the data path from the other Sort component to the Merge Join transformation. This time, the Input Output Selection dialog box does not appear. Instead, the Input drop-down list defaults to the only remaining option: Merge Join Right Input.<\/p>\r\n\r\n\r\n\r\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.sqlfreelancer.com\/blog\/wp-content\/uploads\/2020\/04\/Merge-Join-9.png\"><img loading=\"lazy\" decoding=\"async\" width=\"627\" height=\"560\" class=\"wp-image-805\" src=\"https:\/\/www.sqlfreelancer.com\/blog\/wp-content\/uploads\/2020\/04\/Merge-Join-9.png\" alt=\"\" srcset=\"https:\/\/www.sqlfreelancer.com\/blog\/wp-content\/uploads\/2020\/04\/Merge-Join-9.png 627w, https:\/\/www.sqlfreelancer.com\/blog\/wp-content\/uploads\/2020\/04\/Merge-Join-9-300x268.png 300w\" sizes=\"auto, (max-width: 627px) 100vw, 627px\" \/><\/a><\/figure>\r\n\r\n\r\n\r\n<p>Now, let\u2019s configure the Merge Join transformation.<\/p>\r\n\r\n\r\n\r\n<p>The first setting in the Merge Join Transformation Editor is the Join type drop-down list. From this list, you can select one of the following three join types:<\/p>\r\n\r\n\r\n\r\n<ul class=\"wp-block-list\">\r\n<li>Left outer join: Includes all rows from the left table, but only matching rows from the right table. You can use the Swap Inputs option to switch data source, effectively creating a right outer join.<\/li>\r\n<li>Full outer join: Includes all rows from both tables.<\/li>\r\n<li>Inner join: Includes rows only when the data matches between the two tables.<\/li>\r\n<\/ul>\r\n\r\n\r\n\r\n<p>For our example, we want to include all rows from left table but only rows from the right table if there\u2019s a match, so we\u2019ll use the Left outer join option.<\/p>\r\n\r\n\r\n\r\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.sqlfreelancer.com\/blog\/wp-content\/uploads\/2020\/04\/Merge-Join-10.png\"><img loading=\"lazy\" decoding=\"async\" width=\"690\" height=\"227\" class=\"wp-image-806\" src=\"https:\/\/www.sqlfreelancer.com\/blog\/wp-content\/uploads\/2020\/04\/Merge-Join-10.png\" alt=\"\" srcset=\"https:\/\/www.sqlfreelancer.com\/blog\/wp-content\/uploads\/2020\/04\/Merge-Join-10.png 690w, https:\/\/www.sqlfreelancer.com\/blog\/wp-content\/uploads\/2020\/04\/Merge-Join-10-300x99.png 300w\" sizes=\"auto, (max-width: 690px) 100vw, 690px\" \/><\/a><\/figure>\r\n\r\n\r\n\r\n<p>You now need to select which columns you want to include in the data set that will be outputted by the Merge Join transformation. For this exercise, we\u2019ll include all columns. To include a column in the final result set, simply select the check box next to the column name in either data source.<\/p>\r\n\r\n\r\n\r\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.sqlfreelancer.com\/blog\/wp-content\/uploads\/2020\/04\/Merge-Join-11.png\"><img loading=\"lazy\" decoding=\"async\" width=\"691\" height=\"707\" class=\"wp-image-807\" src=\"https:\/\/www.sqlfreelancer.com\/blog\/wp-content\/uploads\/2020\/04\/Merge-Join-11.png\" alt=\"\" srcset=\"https:\/\/www.sqlfreelancer.com\/blog\/wp-content\/uploads\/2020\/04\/Merge-Join-11.png 691w, https:\/\/www.sqlfreelancer.com\/blog\/wp-content\/uploads\/2020\/04\/Merge-Join-11-293x300.png 293w\" sizes=\"auto, (max-width: 691px) 100vw, 691px\" \/><\/a><\/figure>\r\n\r\n\r\n\r\n<p>Almost finished, but first let\u2019s add a Conditional Split transformation. This will allow us to insert new records or update previous records.<\/p>\r\n\r\n\r\n\r\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.sqlfreelancer.com\/blog\/wp-content\/uploads\/2020\/04\/Merge-Join-12.png\"><img loading=\"lazy\" decoding=\"async\" width=\"784\" height=\"624\" class=\"wp-image-808\" src=\"https:\/\/www.sqlfreelancer.com\/blog\/wp-content\/uploads\/2020\/04\/Merge-Join-12.png\" alt=\"\" srcset=\"https:\/\/www.sqlfreelancer.com\/blog\/wp-content\/uploads\/2020\/04\/Merge-Join-12.png 784w, https:\/\/www.sqlfreelancer.com\/blog\/wp-content\/uploads\/2020\/04\/Merge-Join-12-300x239.png 300w, https:\/\/www.sqlfreelancer.com\/blog\/wp-content\/uploads\/2020\/04\/Merge-Join-12-768x611.png 768w\" sizes=\"auto, (max-width: 784px) 100vw, 784px\" \/><\/a><\/figure>\r\n\r\n\r\n\r\n<p>In the Conditional Split Editor, I created two outputs. If (Destination) ID is NULL then the record doesn\u2019t exist so we\u2019ll perform an INSERT. If the ModifiedDate is different between the two tables then we know something has been updated since the last execution and we need to update the record. See below.<\/p>\r\n\r\n\r\n\r\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.sqlfreelancer.com\/blog\/wp-content\/uploads\/2020\/04\/Merge-Join-13.png\"><img loading=\"lazy\" decoding=\"async\" width=\"663\" height=\"711\" class=\"wp-image-809\" src=\"https:\/\/www.sqlfreelancer.com\/blog\/wp-content\/uploads\/2020\/04\/Merge-Join-13.png\" alt=\"\" srcset=\"https:\/\/www.sqlfreelancer.com\/blog\/wp-content\/uploads\/2020\/04\/Merge-Join-13.png 663w, https:\/\/www.sqlfreelancer.com\/blog\/wp-content\/uploads\/2020\/04\/Merge-Join-13-280x300.png 280w\" sizes=\"auto, (max-width: 663px) 100vw, 663px\" \/><\/a><\/figure>\r\n\r\n\r\n\r\n<p>Since we can perform and INSERT or an UPDATE we\u2019ll need two destinations. First, for the INSERT, we\u2019ll simply be doing an INSERT into the table so we can drag the OLE DB Destination component into the window, choose \u201cINSERT\u201d in the Input Output selection window, and use the Reporting connection manager.<\/p>\r\n\r\n\r\n\r\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.sqlfreelancer.com\/blog\/wp-content\/uploads\/2020\/04\/Merge-Join-14.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"731\" class=\"wp-image-810\" src=\"https:\/\/www.sqlfreelancer.com\/blog\/wp-content\/uploads\/2020\/04\/Merge-Join-14-1024x731.png\" alt=\"\" srcset=\"https:\/\/www.sqlfreelancer.com\/blog\/wp-content\/uploads\/2020\/04\/Merge-Join-14-1024x731.png 1024w, https:\/\/www.sqlfreelancer.com\/blog\/wp-content\/uploads\/2020\/04\/Merge-Join-14-300x214.png 300w, https:\/\/www.sqlfreelancer.com\/blog\/wp-content\/uploads\/2020\/04\/Merge-Join-14-768x548.png 768w, https:\/\/www.sqlfreelancer.com\/blog\/wp-content\/uploads\/2020\/04\/Merge-Join-14.png 1177w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\r\n\r\n\r\n\r\n<p>I\u2019m going to check the \u201cKeep Identity\u201d box since the ID column is an identity column.<\/p>\r\n\r\n\r\n\r\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.sqlfreelancer.com\/blog\/wp-content\/uploads\/2020\/04\/Merge-Join-15.png\"><img loading=\"lazy\" decoding=\"async\" width=\"743\" height=\"560\" class=\"wp-image-811\" src=\"https:\/\/www.sqlfreelancer.com\/blog\/wp-content\/uploads\/2020\/04\/Merge-Join-15.png\" alt=\"\" srcset=\"https:\/\/www.sqlfreelancer.com\/blog\/wp-content\/uploads\/2020\/04\/Merge-Join-15.png 743w, https:\/\/www.sqlfreelancer.com\/blog\/wp-content\/uploads\/2020\/04\/Merge-Join-15-300x226.png 300w\" sizes=\"auto, (max-width: 743px) 100vw, 743px\" \/><\/a><\/figure>\r\n\r\n\r\n\r\n<p>Next, for the UPDATE statement we\u2019ll drag the OLE Command component into the window and configure it. Select \u201cUPDATE\u201d in the Input Output Selection window.<\/p>\r\n\r\n\r\n\r\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.sqlfreelancer.com\/blog\/wp-content\/uploads\/2020\/04\/Merge-Join-16.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"581\" class=\"wp-image-812\" src=\"https:\/\/www.sqlfreelancer.com\/blog\/wp-content\/uploads\/2020\/04\/Merge-Join-16-1024x581.png\" alt=\"\" srcset=\"https:\/\/www.sqlfreelancer.com\/blog\/wp-content\/uploads\/2020\/04\/Merge-Join-16-1024x581.png 1024w, https:\/\/www.sqlfreelancer.com\/blog\/wp-content\/uploads\/2020\/04\/Merge-Join-16-300x170.png 300w, https:\/\/www.sqlfreelancer.com\/blog\/wp-content\/uploads\/2020\/04\/Merge-Join-16-768x436.png 768w, https:\/\/www.sqlfreelancer.com\/blog\/wp-content\/uploads\/2020\/04\/Merge-Join-16.png 1136w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\r\n\r\n\r\n\r\n<p>In the Connection Managers tab, assign the connection manager for Reporting.<\/p>\r\n\r\n\r\n\r\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.sqlfreelancer.com\/blog\/wp-content\/uploads\/2020\/04\/Merge-Join-17.png\"><img loading=\"lazy\" decoding=\"async\" width=\"613\" height=\"367\" class=\"wp-image-813\" src=\"https:\/\/www.sqlfreelancer.com\/blog\/wp-content\/uploads\/2020\/04\/Merge-Join-17.png\" alt=\"\" srcset=\"https:\/\/www.sqlfreelancer.com\/blog\/wp-content\/uploads\/2020\/04\/Merge-Join-17.png 613w, https:\/\/www.sqlfreelancer.com\/blog\/wp-content\/uploads\/2020\/04\/Merge-Join-17-300x180.png 300w\" sizes=\"auto, (max-width: 613px) 100vw, 613px\" \/><\/a><\/figure>\r\n\r\n\r\n\r\n<p>In the Connection Managers tab, assign the connection manager for Reporting.<\/p>\r\n\r\n\r\n\r\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.sqlfreelancer.com\/blog\/wp-content\/uploads\/2020\/04\/Merge-Join-18.png\"><img loading=\"lazy\" decoding=\"async\" width=\"721\" height=\"744\" class=\"wp-image-814\" src=\"https:\/\/www.sqlfreelancer.com\/blog\/wp-content\/uploads\/2020\/04\/Merge-Join-18.png\" alt=\"\" srcset=\"https:\/\/www.sqlfreelancer.com\/blog\/wp-content\/uploads\/2020\/04\/Merge-Join-18.png 721w, https:\/\/www.sqlfreelancer.com\/blog\/wp-content\/uploads\/2020\/04\/Merge-Join-18-291x300.png 291w\" sizes=\"auto, (max-width: 721px) 100vw, 721px\" \/><\/a><\/figure>\r\n\r\n\r\n\r\n<p>In the column mappings tab, assign parameters:<\/p>\r\n\r\n\r\n\r\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.sqlfreelancer.com\/blog\/wp-content\/uploads\/2020\/04\/Merge-Join-19.png\"><img loading=\"lazy\" decoding=\"async\" width=\"714\" height=\"739\" class=\"wp-image-815\" src=\"https:\/\/www.sqlfreelancer.com\/blog\/wp-content\/uploads\/2020\/04\/Merge-Join-19.png\" alt=\"\" srcset=\"https:\/\/www.sqlfreelancer.com\/blog\/wp-content\/uploads\/2020\/04\/Merge-Join-19.png 714w, https:\/\/www.sqlfreelancer.com\/blog\/wp-content\/uploads\/2020\/04\/Merge-Join-19-290x300.png 290w\" sizes=\"auto, (max-width: 714px) 100vw, 714px\" \/><\/a><\/figure>\r\n\r\n\r\n\r\n<p>Final package should look like the following:<\/p>\r\n\r\n\r\n\r\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.sqlfreelancer.com\/blog\/wp-content\/uploads\/2020\/04\/Merge-Join-20.png\"><img loading=\"lazy\" decoding=\"async\" width=\"855\" height=\"738\" class=\"wp-image-816\" src=\"https:\/\/www.sqlfreelancer.com\/blog\/wp-content\/uploads\/2020\/04\/Merge-Join-20.png\" alt=\"\" srcset=\"https:\/\/www.sqlfreelancer.com\/blog\/wp-content\/uploads\/2020\/04\/Merge-Join-20.png 855w, https:\/\/www.sqlfreelancer.com\/blog\/wp-content\/uploads\/2020\/04\/Merge-Join-20-300x259.png 300w, https:\/\/www.sqlfreelancer.com\/blog\/wp-content\/uploads\/2020\/04\/Merge-Join-20-768x663.png 768w\" sizes=\"auto, (max-width: 855px) 100vw, 855px\" \/><\/a><\/figure>\r\n\r\n\r\n\r\n<p>Save and execute. You can see that we updated two records and inserted one record:<\/p>\r\n\r\n\r\n\r\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.sqlfreelancer.com\/blog\/wp-content\/uploads\/2020\/04\/Merge-Join-21.png\"><img loading=\"lazy\" decoding=\"async\" width=\"799\" height=\"686\" class=\"wp-image-817\" src=\"https:\/\/www.sqlfreelancer.com\/blog\/wp-content\/uploads\/2020\/04\/Merge-Join-21.png\" alt=\"\" srcset=\"https:\/\/www.sqlfreelancer.com\/blog\/wp-content\/uploads\/2020\/04\/Merge-Join-21.png 799w, https:\/\/www.sqlfreelancer.com\/blog\/wp-content\/uploads\/2020\/04\/Merge-Join-21-300x258.png 300w, https:\/\/www.sqlfreelancer.com\/blog\/wp-content\/uploads\/2020\/04\/Merge-Join-21-768x659.png 768w\" sizes=\"auto, (max-width: 799px) 100vw, 799px\" \/><\/a><\/figure>\r\n\r\n\r\n\r\n<p>Going back to our query you can see that everything matches up now:<\/p>\r\n\r\n\r\n\r\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.sqlfreelancer.com\/blog\/wp-content\/uploads\/2020\/04\/Merge-Join-22.png\"><img loading=\"lazy\" decoding=\"async\" width=\"721\" height=\"494\" class=\"wp-image-818\" src=\"https:\/\/www.sqlfreelancer.com\/blog\/wp-content\/uploads\/2020\/04\/Merge-Join-22.png\" alt=\"\" srcset=\"https:\/\/www.sqlfreelancer.com\/blog\/wp-content\/uploads\/2020\/04\/Merge-Join-22.png 721w, https:\/\/www.sqlfreelancer.com\/blog\/wp-content\/uploads\/2020\/04\/Merge-Join-22-300x206.png 300w\" sizes=\"auto, (max-width: 721px) 100vw, 721px\" \/><\/a><\/figure>\r\n","protected":false},"excerpt":{"rendered":"<p>I was asked a question awhile back on the easiest way to do an incremental load from one SQL Server table into another SQL Server table. This is common in data warehouses or reporting tables as you wouldn\u2019t want to truncate a large table and perform a full insert. Instead, you would want to only [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[30,49,139],"tags":[124,83,60,50],"class_list":["post-794","post","type-post","status-publish","format-standard","hentry","category-business-intelligence","category-integration-services-ssis","category-ssis-series","tag-sql-server-2019","tag-sql-server-business-intelligence","tag-sql-server-integration-services","tag-ssis"],"_links":{"self":[{"href":"https:\/\/www.sqlfreelancer.com\/blog\/wp-json\/wp\/v2\/posts\/794","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.sqlfreelancer.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.sqlfreelancer.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.sqlfreelancer.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.sqlfreelancer.com\/blog\/wp-json\/wp\/v2\/comments?post=794"}],"version-history":[{"count":4,"href":"https:\/\/www.sqlfreelancer.com\/blog\/wp-json\/wp\/v2\/posts\/794\/revisions"}],"predecessor-version":[{"id":863,"href":"https:\/\/www.sqlfreelancer.com\/blog\/wp-json\/wp\/v2\/posts\/794\/revisions\/863"}],"wp:attachment":[{"href":"https:\/\/www.sqlfreelancer.com\/blog\/wp-json\/wp\/v2\/media?parent=794"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.sqlfreelancer.com\/blog\/wp-json\/wp\/v2\/categories?post=794"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.sqlfreelancer.com\/blog\/wp-json\/wp\/v2\/tags?post=794"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}