What is the best was I can open a txt file
in a SSIS
and store the first line as a variable.
I want to put a list of accounts in the txt file
and use them in a SQL task
.
What is the best was I can open a txt file
in a SSIS
and store the first line as a variable.
I want to put a list of accounts in the txt file
and use them in a SQL task
.
Refer to the link @Ozren gave you, to create a proper flat file connection e.g myfile
and variable e.g.HeaderLine
. Then create a script task, put HeaderLine var in read/write variables
and code it with:
System.IO.StreamReader file =
new System.IO.StreamReader(Dts.Connections["myfile"].ConnectionString);
Dts.Variables["HeaderLine"].Value = file.ReadLine();
file.Close();
That's pretty much it, then you can put a standard DataFlow to read filedata from file to DB or resultset.
You'll have the first line in HeaderLine variable, which you can use anywhere you want in the SSIS package.