Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > SQL Server > SQL Server 2005 > SQL Server 2005
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old January 10th, 2008, 03:52 AM
Registered User
 
Join Date: Dec 2007
Location: , , India.
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
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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 03:47 PM
COM Surrogate crmpicco Classic ASP Basics 7 May 12th, 2005 10:33 AM
"Found a low surrogate char without a preceding hi rosalynb VS.NET 2002/2003 6 May 18th, 2004 07:48 PM



All times are GMT -4. The time now is 10:33 PM.


Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.