Scrpting to genrate surrogate keys
This is the code iam using to get the incremental surrogate keys:
Imports System
Imports System.Data
Imports System.Math
Imports Microsoft.SqlServer.Dts.Pipeline.Wrapper
Imports Microsoft.SqlServer.Dts.Runtime.Wrapper
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 = 1093
End Sub
'This method gets called for each row in the InputBuffer
Public Overrides Sub Input_ProcessInputRow(ByVal Row As InputBuffer)
'Increment the variable
counter += 1
'Output the value of the variable
Row.instance = counter
End Sub
End Class
--'Instance' is my surrogate feild name
but iam getting an error saying thatInputBuffer is not defined ..Any idea?
If I want to add two more incrementive fileds ,where i have to add it?
Sorry if it sounds silly ,iam very new to this scripting.
Thanks
Niru
[1136 byte] By [
Niru] at [2007-12-20]
When you first open the script the ProcessInputRow method will be defined for you. InputBuffer if is a generated class, so depending on what you called your input this can change. The default name for the input is "Input 0", so the default name for the buffer class is "Input0Buffer". In the VSA editor, look in the project explore for a file BufferWrapper, this should be your generated buffer class. What is it called? Used that name.
If you want to add more fields, first go into the Inputs and Outputs page of the transformation editor, select the output you want, expand to columns, then click Add Column.
Now when you go back to the script editor, the new column should be a property of the buffer, e.g. Row.NewColumn
If you just need simple incrementing key values, custom seed and increment, then try this- http://www.sqlis.com/default.aspx?93