Surrogate key
Hi,
In my package i need to implement surrogate key on sequence wise.any one can help.ASAP
Ex: custid product date
100 pepsi 12/9/07
101 coke 13/7/06
For this i generated surrogate key using the following code.
__________________________________________________ __________
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 = 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.Sk = counter
End Sub
End Class
__________________________________________________ ____
for this the out put is:
sk id custid product date
1 100 pepsi 12/9/07
2 101 coke 13/7/06
It is ok.
But my data is like this.
custid product date
100 pepsi 12/9/07
101 coke 13/7/06
100 Dye coke 10/1/08
101 coke 10/1/08
I want out put like this
skid custid product date
1 100 pepsi 12/9/07
2 101 coke 13/7/06
1 100 Dye coke 10/1/08
2 101 coke 10/1/08
if the customerid is same it will generate same SKID.
ss
|