Reputation: 405
I have File_Name as ReadOnlyVariable in Script Component and I want to store this as output to use later in the package. Created Output column (myColumn) in Inputs and Outputs. Now trying to populate myColumn as File_Name
public override void CreateNewOutputRows()
{
MyOutputBuffer.AddRow();
MyOutputBuffer.MyColumn = ??User::FILE_NAME
}
How to put File_Name variable in MyColumn?
Upvotes: 3
Views: 11733
Reputation: 61211
A script component allows you access SSIS variables in the Variables collection, once you've added them to the read or read/write collection.
The syntax for doing so is
MyOutputBuffer.MyColumn = Variables.FILE_NAME;
A script task is different in that you would need to access the Value method and then cast to the resulting value from Object to the correct type.
There are two other ways of adding the value of FILE_NAME into your Data flow. The second and more SSIS-centric way would be to use a Derived Column Component with an expression like
@[User::FILE_NAME]
assuming that you've defined this as a new column named MyColumn and have a type like DT_WSTR(120)
The other, assuming this was a Flat File Source, is to go to the Advanced properties and include the filename as a column.
I blogged about the latter approaches under What is the name of current file if you're looking for a thrilling read.
Upvotes: 3