Transferring Master and Detail Data from a Single Flat File to a Different Database Using Sql Server Integration Services

The example we are going to see explains how to transfer the Master records to a Master file destination & detail records to a detail file destination from a single flat file source, using SQL Server Integration Services.

The example we are going to see explains how to transfer the Master records to a Master file destination & detail records to a detail file destination from a single flat file source, using SQL Server Integration Services.

dt0610-1.jpg

We have used a flat file as a source file and created some records as Master and Detail records in the file. In this source file, ‘M’ indicates it is a master record, and ‘D’ indicates it is a detail record

dt0610-2.jpg

In the Flat File Connection Manager Editor of SQL Server, first, we should add the new flat file Connection. Next, we should specify the name of the connection manager and also the row delimiter for the source file. The flat file source will read data from the text file, which can be in a delimited, fixed width or mixed format. To learn more, follow the link Flat File Connection Manager Editor

dt0610-3.jpg

Next, select the Dataflow Task in our package and add the Flat file source. Double click the flat file source and then select the columns. Using the Columns node, map the externals columns to output columns. The output column provides unique names for each output column.

dt0610-4.png

Now, we have to use the Conditional Split Transformation Editor to define the logic to split the data. The Conditional split Transformation is used to split the source depending on the content of the data. In this example, the lines end with ‘M’ will be created as Master records, and the lines end with ‘D’ will be created as Detail records.

To learn more about Conditional Split Transformation, please go through the link Conditional Split Transformation.

dt0610-5.png

So, using Conditional Split Transformation editor, we have defined the split logic. Next, we have to create a Script component for data transformation. If we use Script component for source, it will support multiple outputs. If we use Script Component for Transformation, It will support one input and multiple outputs, but the Script component for Destination will support one input.

Based on our example here, we have to use the Script Component for source, so it can support multiple outputs. To know more about Script Transformation using SSIS.

dt0610-6.png
dt0610-7.png

After finishing the above coding, we should run the package. Now, it shows the boxes in green color to indicate the package execution is successful. From the source file we have moved four records to the destination. Based on the Split condition, one record is created as a Master record, and three records are created as Detail record.

dt0610-8.png

The SQL Server Integration Service is an effective tool for splitting and transferring a single flat file into multiple database files using conditions.

About MST

At MST Solutions our cornerstone is to adapt, engage and create solutions which guarantee the success of our clients. The talent of our team and experiences in varied business verticals gives us an advantage over other competitors.

Recent Articles

Harnessing Generative AI in Healthcare Insurance: Streamlining Operations and Enhancing Member Insights

Healthcare insurance providers are navigating new ground and capitalizing on new opportunities made possible through artificial intelligence. AI can be utilized to lower costs for payers and improve the member experience as well as the overall health and well-being of members, leading to greater member satisfaction and improving trust and reputation for the payer’s brand.

Read Article »

Work with us.

Our people aren’t just employees, they are key to the success of our business. We recognize the strengths of each individual and allow them time and resources to further develop those skills, crafting a culture of leaders who are passionate about where they are going within our organization.