I'm fairly new to SSIS and I'm having a bit of a problem splitting a CSV into multiple files by row.
I have a CSV with multiple rows - I am trying to split each row into a new flat file and make each column a new line in the flat file.
I currently have a flat file source pumping into a derived column and sorting the data into the format I want. To test this I outputted it into 1 large flat file with multiple rows however I would ideally like to create a file for each row.
I have tried using a for each to loop through but I'm not quite sure how to use it in SSIS.
Any help would be appreciated - Thanks in advance.
I think you don't need a loop, a C# script will do the trick. With blocks defined as:
Source -> [RowCounter into variable Counter
] -> [Script Task] -> Destination
Script Task:
int val = Convert.ToInt32(Dts.Variables["Counter"].Value);
Dts.Connections["destinationConnectionName"].ConnectionString = "c:\\yourpath\\" + val.ToString() + ".txt";
of course you have to specify readonly parameter: Counter.
This will set the connection name for each row. Combine it with sorting, which you already have.
You can use the Multicast Transformation in a Data Flow to send each record derived from your Flat File Source to two or more Flat File Destinations. This may be a more efficient way to use SSIS than using a loop container or a script task.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.