SQL Server Integration Services: Merge Join Transformation

Leave a comment (0) Go to comments

This is a guest post by Girish Khullar, If you want to guest post on this blog, contact me .

What is Merge Join Transformation?

You may have gone through this question a lot of time while working that what is the thumb rule to use Look Up transformation or Merge Transformation. Lets have a simple rule for that:

While using Lookup component, thumb rule is to make sure that the largest table i.e. a fact table gets streamed into the component and the smallest table i.e dimension table gets cached. The reason behind this is that the table that gets cached will block the flow while it is loaded into the memory, so it is good to have it as small as possible.

So, if the table to be cached in memory is large, use the MERGE Join component. But there are few pre-requisites that one must follow while working on the Merge Join:

  1. It requires the inputs to be sorted in the same way.
  2. We need to set ISSORETD property TRUE in advanced editor of input source component.
  3. But till now, we have told the component that the data is sorted but in which order? Under Input/Output properties of source component, we need to check the value of SortKeyPosition for the particular columns that are used for sort. If the column is not sorted then vale of SortKeyPosition must be 0. If the sorting is in ascending order, the value should be positive and if it is in descending order then it should be in negative.

For example, lets take a query:

select empID, empName, EmpDepttID from employees
order by empid , empName

for this, value of my SortkeyPosition would be

Column                SortKeyPosition

empID                    1

empName              2

EmpDepttID           0

Merge Join transformation, gives us the option to use Inner Join, Left Outer Join and Full Outer Join.

 

SQL Server Integration Services: Merge Join Transformation

Looking at the above figure, one must wonder, where is the option to use Right outer join. On Join Type combo, select Left outer join, this will activate Swap Inputs button, which allows you to use right outer join by just placing your join table on left. Something I liked :)

About the Author: SQL Server Integration Services: Merge Join Transformation  Girish Khullar, writes about SQL Server, Integration Services and Business Intelligence.  He is Microsoft Certified Professional.

 

EOF - SQL Server Integration Services: Merge Join Transformation, SQL Server 2012 , 2008 R2 , 2008 , 2005 , 2000

Leave a Reply

Your email address will not be published. Required fields are marked *


*


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Notify me of followup comments via e-mail. You can also subscribe without commenting.