populate output column in script component
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.
Related videos on Youtube
user2841795
Updated on June 04, 2022Comments
-
user2841795 almost 2 years
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?
-
Matt Rowland almost 8 yearsYour question is unclear. What is
FILE_NAME
? What isMyColumn
? What do you mean by "store this as output"? -
user2841795 almost 8 yearsQuestion is edited now.
-