.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Home >> Articles >> DataBase >> Post New Resource Bookmark and Share   

 Subscribe to Articles

Merge Transformation in SSIS - SQL Server Integration Services (SSIS) - Part 50

Posted By:Karthikeyan Anbarasan       Posted Date: May 04, 2011    Points: 200    Category: DataBase    URL: http://www.dotnetspark.com  

In this article we are going to see on how to use Merge transformation in SQL Server Integration Services (SSIS) Packaging.


In this article we are going to see how to use Merge transformation in SSIS Packaging. Merge transformation is used in cases where we need to get data from 2 different data sources and merge then in the order specified and send the result to the destination. Merge transformation can be very effective when we need to do manipulation across the data sets or the data source. Let's jump start how to use this task in real time and see the steps to do the configurations.

You can also read my other articles on SSIS from here. 


Follow steps 1 to 3 of my first article to open the BIDS project and select the right project to work on an integration services project. Once the project is created, we will see how to use the Merge Transformation task. Once you open the project just drag and drop the Merge transformation control and a source provider is shown in the image below.


Now we need to start configuring the transformation. Let us start with configuring the source data; for that we need to create a table as shown in the screen below.



Create table Merger1(   Empid int,EmpName Varchar(50)) 
Create table Merger2(   Empid int, EmpName Varchar(50)) 
Insert into Merger1 values (1,'Arun') 
Insert into Merger1 values (3,'Karthik') 
Insert into Merger1 values (4,'Amit') 
Insert into Merger1 values (6,'Vinoth') 
Insert into Merger2 values (2,'Vijay') 
Insert into Merger2 values (3,'Karthik') 
Insert into Merger2 values (5,'Ruthesh') 
Insert into Merger2 values (7,'Ruthra') 
Select * from Merger1 
Select * from Merger2 

To configure the sources we need to do the steps below. Here we are going to use a query to fetch the data as shown below:

Select Empid,EmpName From Merger1 Order by Empid 
Select Empid,EmpName From Merger2 Order by Empid 

Your screen looks like below after you configure the first data source.


Similarly do the second data source as shown below:


Now once the sources are configured we need to configure the Merge transformation task by mapping both the merger source with the merge as shown below.


Here we need to do some steps to make the Merge task accept the sources; for this we need to set the sorting to true. Since the task by itself will not do the sorting to merge the data. For that you need to right-click on the sources task and select "Show advanced editor" and select the input output properties tab and click on the OLEDB Source output. Then change the IsSorted property to True on the output. 

Now we are done with configuration of the sources and the merge task. Now we need to get the output; for that we can use a flat file destination as shown in the screen below: 


Now execute the task (Press F5); you will get the desired output as shown below.


We can see the output in the file which we specified at the configuration of the destination task.



So in this article we have seen how to use the Merge transformation task and the key configurations used in order to use this task easily.

 Subscribe to Articles


Further Readings:


No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More Articles on C#, ASP.Net, Vb.Net, SQL Server and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend