Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Use SSIS to create index column

Status
Not open for further replies.

Flybridge

MIS
Jul 7, 2003
130
GB
Anyone know the syntax and function to get SSIS to populate a derived column with a self incrementing index? I'm using the Derived Column tool but can't find an index or rowcount/rownumber function.

Thanks.

'The world isn't round - it's bent!' Spike Milligan
 
Answered my own question.
Use the Script object and define it as transforming. Make the script look like this.

Public Class ScriptMain
Inherits UserComponent
'Declare a variable scoped to class ScriptMain
Dim counter As Integer
Public Sub New() ' This method gets called only once per execution
'Initialise the variable
counter = 0
End Sub
'This method gets called for each row in the InputBuffer
Public Overrides Sub Input0_ProcessInputRow(ByVal Row As Input0Buffer)
'
' Increment the variable
'
counter += 1
' Output the value of the variable
Row.Index = counter
End Sub


'The world isn't round - it's bent!' Spike Milligan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top