SSIS – read a file based on file name parameter

Possibly save 1 hour of your time: There are times you will need to read a file and process the data in it.

In this scenario, there is an input for the file name with path and an output with the second line parsed.


public void Main()
			// TODO: Add your code here

                using (var reader = new StreamReader(Dts.Variables["SupportListFile"].Value.ToString()))
//custom code to read first and second line
//read first line
//read second line
                    var list = reader.ReadLine();

//assign output variable
                    if (!string.IsNullOrEmpty(list))
                        Dts.Variables["SupportList"].Value = list;

            Dts.TaskResult = (int)ScriptResults.Success;

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s