Wrox Programmer Forums
|
SQL Server 2005 General discussion of SQL Server *2005* version only.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2005 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 10th, 2008, 03:52 AM
Registered User
 
Join Date: Dec 2007
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to ssaranam
Default 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





Similar Threads
Thread Thread Starter Forum Replies Last Post
Surrogate ssaranam SQL Server 2005 1 December 14th, 2007 02:32 AM
<bean:message key="PNR.INPUT"/> key has null value warsha_14 Struts 1 November 13th, 2006 07:26 AM
TAB KEY working together KEY PRESS event thomaz C# 4 August 20th, 2006 02:47 PM
COM Surrogate crmpicco Classic ASP Basics 7 May 12th, 2005 09:33 AM
"Found a low surrogate char without a preceding hi rosalynb VS.NET 2002/2003 6 May 18th, 2004 06:48 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.