Sometimes it's useful to add a row number to rows passing along an SSIS data flow e.g.
This article describes a script component pattern for doing so.
RowNumber and a DataType of DT_I4 (this is the default)
public class ScriptMain : UserComponent. This is the declaration of the ScriptMain class.
The pattern uses an internal rowNumber variable to count how many rows have passed through the transformation.
PreExecute() method.Input0_ProcessInputRow is called). The new value represents the number of rows that have now passed through the transformation – i.e. the number of the current row. This value is written into the row's RowNumber column.public class ScriptMain : UserComponent { private int rowNumber; public override void PreExecute() { base.PreExecute(); rowNumber = 0; } public override void Input0_ProcessInputRow(Input0Buffer Row) { rowNumber++; Row.RowNumber = rowNumber; } }