Merge Join Transformation in SSIS 2008R2 Example

143
20481
merge transformation

Merge Join Transformation is one of the useful tool in SSIS to join two sources. The Merge Join transformation provides an output that is generated by joining two sorted datasets using a FULL, LEFT, or INNER join. Let us see how it works.
You can configure the Merge Join transformation in the following ways:
• Specify the join as FULL, LEFT, or INNER join.
• Specify the columns the join uses.
• Specify whether the transformation handles null values as equal to other nulls.
NOTE: If null values are not treated as equal values, the transformation handles null values like the SQL Server Database Engine does.

This transformation has two inputs and one output. It does not support an error output. Let’s discuss the same with an example. We will start out with a connection manager that is created for the Adventure works database

Now drag and drop a Data Flow Task from the toolbox. Now Double click on Data flow Task.

Now we will create an OLE DB Source called “Products”, in which we will select all of the products (see query below).

Double click on the Products OLE DB Source and the OLE DB Source Editor will appear. We select SQL Command from the Data Access Mode and will specify the query. This query will select the ProductID, Name, ProductNumber, and ProductSubcategoryID from the Product table.

Now Create an OLE DB Source called “Product Subcategory”, in which we will select all of the Product Categories .

Now Double click on the Product Subcategory OLE DB Source and the OLE DB Source Editor will appear. We select SQL Command from the Data Access Mode and will specify the query. This query will select the ProductSubcategoryID, and Name from the ProductCategory table.

Now Create an OLE DB Source called “Purchase Order Detail”, in which we will select all of the Details of the Purchase Orders.

Double click on the Purchase Order Detail OLE DB Source and the OLE DB Source Editor will appear. We select SQL Command from the Data Access Mode and will specify the query. This query will select the PurchaseOrderID, ProductID, and UnitPrice from the PurchaseOrderDetail table.

Now we will create two Sort components and join the pipeline from Products to one of the sort transformations and join the pipeline from Product Subcategory to the other sort transformation. Remember that both datasets that you are joining must be sorted the same before joining with a Merge Join.

Now Click on the Sort that we connected to the Products source and the Sort Transformation Editor will appear. We want to sort this dataset by ProductSubcategoryID, so click on the checkbox to the left of ProductSubcategoryID. This will put ProductSubcategoryID in the lower box. Now we can click OK when we are complete.

Click on the Sort that we connected to the Product Subcategory source and the Sort Transformation Editor will appear. We want to sort this dataset by ProductSubcategoryID, so click on the checkbox to the left of ProductSubcategoryID. This will put ProductSubcategoryID in the lower box. Now we can click OK when we are complete.

Now add a Merge Join transformation. This will allow us to join the Products and Product Subcategory sources together. Drag the pipeline arrow from the Products Sort to the Merge Join.

The Input Output Selection window will appear. Select Merge Join Left Input. This will mean that we are using the Products on the Left hand side of the join. If you are familiar with Left and Right joins in SQL this is a familiar concept. Choosing Left Input doesn’t mean we are necessarily doing an outer or inner join (we define that later), it just defines what side of the join this input will be used as.

Now drag the pipeline arrow from the Product Subcategory Sort to the Merge Join. This time it will most likely not prompt you for which side of the join you want to add this input, as we already selected Left Input for the previous input.

Now we will double click on the Merge Join and the Merge Join Transformation Editor will appear. You will notice that ProductSubcategoryID from both datasets has a line connected to each other. This means that this is the column that we are joining on. You will also notice that the Join Type can be “Inner Join”, “Left Outer Join” or “Full Outer Join”. In order to retain the other columns in the pipeline click on the checkboxes to the left of the column names. If any of the boxes to the left of the columns are not checked, it means that column will no longer be in the pipeline after the Merge Join. Notice that below there is a column called “Output Alias”. This column allows us to rename columns to new names. This allows us to rename “Name” from Products to “ProductName” and renam “Name” from ProductSubcategory to “CategoryName”. So after the Merge Join, this columns will now be known be these alias names. When completed click OK.

Now we will create two Sort components and join the pipeline from the Merge Join to one of the sorts and join the pipeline from the Purchase Order Detail source to the other sort.

Now Click on the Sort that we connected to the Merge Join output and the Sort Transformation Editor will appear. We want to sort this dataset by ProductID, so click on the checkbox to the left of ProductID. This will put ProductID in the lower box. Now we can click OK when we are complete.

Click on the Sort that we connected to the Purchase Order Detail source and the Sort Transformation Editor will appear. We want to sort this dataset by ProductID, so click on the checkbox to the left of ProductID. This will put ProductID in the lower box. Now we can click OK when we are complete.

Now we will add a Merge Join transformation. This will allow us to join the Results of the first Merge Join and the Purchase Order Detail source together. Drag the pipeline arrow from the sort transformation of the first Merge Join to the Merge Join. The Input Output Selection window will appear. Select Merge Join Left Input. Then drag the pipeline arrow from the Purchase Order Detail sort to the Merge Join.

Now we will double click on the Merge Join and the Merge Join Transformation Editor will appear. You will notice that ProductID from both datasets has a line connected to each other. This means that this is the column that we are joining on. You will also notice that the Join Type can be “Inner Join”, “Left Outer Join” or “Full Outer Join”. In order to retain the other columns in the pipeline click on the checkboxes to the left of the column names. If any of the boxes to the left of the columns are not checked, it means that column will no longer be in the pipeline after the Merge Join. Click OK hen completed.

Instead of using OLEDB as destination, I used Audit Transformation for testing purpose and used Data viewer to show output data produced by Merge join Transformation. After testing our package successfully we can delete Audit Transformation and Data Viewer and bring our destination and connect to Merge Join transformation for input columns for our destination.

Now Execute the package to see the Results.

Now we can output our joined dataset to any source we desire. I Hope you are now able to successfully join datasets using SSIS.

Hope you will give a try !!

Thanks Aparna for the document.

Regards,
Roopesh Babu V

143 COMMENTS

  1. As for the consequences, FDA associate commissioner for planning and policy William Hubbard told the Wall Street Journal in March 2003 that any party participating in an import plan in which a health insurer or claims processor helps arrange a purchase in Canada does so at its own legal risk buying cialis generic 31 per tablet for 7,500 tabs

  2. “I put him in the Champagne (Stakes, Doncaster) this morning, he’s in the National Stakes in Ireland. There are lots of lovely options for him. He now warrants a trip anywhere. Completing the CAPTCHA proves you are a human and gives you temporary access to the web property. It’s official – the ChampagneSpins welcome package is totally rewarding ever! Get another great bonus on your fourth deposit! New casino users offer bonuses for first deposits: Completing the CAPTCHA proves you are a human and gives you temporary access to the web property. At Casino Robots, you can find a wide variety of free casino games, slots, poker, roulette, blackjack, baccarat, keno, bingo, craps, and many more table and card games that you can play online. By using this site, you agree to our terms of service and privacy policy. https://spencerpjyn542087.blogdosaga.com/13499785/casino-slots-no-deposit-free-spins CONTACT FORM BITCOINTALK Bitcasino.io is the world’s first legally licensed and regulated online Bitcoin-only gaming platforms. Kopikas Enterprises d.o.o. has been granted a gambling license to conduct online gaming operations by the government of Montenegro under the License# 0042 for the website BitCasino.io BitStarz casino is an online casino brand that offers a large collection of table games and slots for international players. The platform supports both crypto and fiat currencies as deposits or withdrawals. The instant-play feature allows using the platform on any mobile or desktop device without the need for installing the software. Other examples of gambling websites that accept crypto are Bitsler, Cloudbet, Bitcoincasino.us, and BetChain. Choosing the crypto casino that’s best for you is entirely subjective, but there are some sites out there that stand out and bring the most satisfactory service to players around the world. Among those are FortuneJack, Satoshi Casino, CloudBet, mBit, BitCasino, Bovada Casino, and Primedice. Only by trying out and using the websites can you develop your own personal preferences and find out the one that suits you best, so make sure to use a couple of trial periods or demo play options on multiple casinos to be completely sure of your choice.

  3. I’ve been searching for hours on this topic and finally found your post. casinosite, I have read your post and I am very impressed. We prefer your opinion and will visit this site frequently to refer to your opinion. When would you like to visit my site?

  4. The Simcoe County LINX inter-community bus service’s 2 Wasaga Beach to Barrie route has stops in Clearview at the Brentwood Community Centre in Brentwood and the Clearview Administration Centre in Stayner. The digital revolution has come to the marijuana community. You can now buy weed online for Canada Post delivery to your Collingwood address. Just like any online store, all you need to do is fill up your online cart, place a secure order, and then wait for the mail to arrive. Mail order marijuana is a new level of convenience that makes it easy to source amazing cannabis at any time of day. “Given the size of our city, Toronto’s needs and responsibilities when it comes to marijuana are more extensive than those of any other Canadian city and should be recognized accordingly,” he added. https://www.disabilitymedwaynetwork.org.uk/community/profile/emilmjh17683134/ Around the same time, American scientists start studying ‘shrooms. In doing so, they enlist the help of Swiss scientist Albert Hoffman, known as the “father” of LSD. He’s probably a really interesting guy. He’s also the first person to extract the psilocybin from the mushrooms Wasson brings to the states from Oaxaca. Hoffman designates the chemical as the reason ‘shrooms make people feel a little whacky. Also known as the Scotch bonnet, fairy ring mushrooms grow throughout the United States, and can be found on Colorado’s fields, lawns, and open areas. Confusingly, these mushrooms don’t typically grow in “fairy ring” circles like other mushroom species are known for. Fairy ring mushrooms are edible, and boast a sweet flavor profile that can be used in everything from baked goods to soups. However, these mushrooms are notoriously difficult to identify.

LEAVE A REPLY

Please enter your comment!
Please enter your name here

93 − = 83