copy data and increment one column value

  • I am trying to copy data from one database table to another database table. Both tables have the same name, however,

    each table is configured differently. The DTSDestination table has an Identity and Identity Seed of 1; however, the

    DTSSource does not. What I need help with is how to auto insert an incremented value in the Student_RecordID column.

    '**********************************************************************

    ' Visual Basic Transformation Script

    ' Copy each source column to the

    ' destination column

    '************************************************************************

    Function Main()

    ' Need help here

    'DTSDestination("Student_RecordID") = ??????????

    ' continue with dts

    DTSDestination("StudentID") = DTSSource("UserID")

    DTSDestination("Student_Email") = DTSSource("EMailAddress")

    DTSDestination("Student_FName") = DTSSource("FName")

    DTSDestination("Student_LName") = DTSSource("LName")

    DTSDestination("Student_Title") = DTSSource("Title")

    DTSDestination("Student_Phone") = DTSSource("Phone")

    DTSDestination("Student_OrgType") = DTSSource("OrgType")

    DTSDestination("Student_Password") = DTSSource("PWord")

    DTSDestination("Student_DODVC") = DTSSource("DODVC")

    DTSDestination("Student_DODCompany") = DTSSource("DODCompany")

    DTSDestination("Student_DODSA") = DTSSource("DODSA")

    DTSDestination("Student_GovEmployee") = DTSSource("GovEmployee")

    DTSDestination("Student_GOVSA") = DTSSource("GOVSA")

    DTSDestination("RegDate") = DTSSource("RegDate")

    Main = DTSTransformStat_OK

    End Function

    Thanks...

    Edited by - matthersjr on 03/18/2003 10:01:54 AM

  • Do not set IDENTITY INSERT ON and don't insert anything for the recordid.

    Steve Jones

    sjones@sqlservercentral.com

    http://www.sqlservercentral.com/columnists/sjones

    http://www.dkranch.net

  • Steve,

    Thanks for the reply. If I remove the identity and perform the copy, I'll have to reset the Identity. How will this effect the current recorders? Will they acquire an incremented identity?

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply