Results 1 to 4 of 4
  1. #1
    Join Date
    Feb 2004
    Posts
    15

    Unanswered: Incrementing an id field

    Hi

    Does anyone know why an error occurs (constraints violated) when I try to have a table with an automated id incrementing by 1. I am uploading the data into the table from dts, so ignore the id field in the dts transformation.

    Any ideas or help would really be appreciated, do I need to reference the id field in an activeX script?

    Thanks

  2. #2
    Join Date
    Mar 2004
    Posts
    6
    Hi

    if the column is having the identity field, then you need to
    set the identity insert on. use the following syntax

    SET IDENTITY_INSERT ON.

    do not allow null in the column while inserting the data into the table. Use incremented loop , to insert the values in the identity field.

    After insert is done use the command

    SET IDENTITY_INSERT OFF

    and in the column property, give the seed value , whatever is the last or max value of the ideneity field after insert.

  3. #3
    Join Date
    Feb 2004
    Posts
    15
    Hi

    Thanks for the reply...is this done in tha activeX script part?

    Thanks

  4. #4
    Join Date
    Feb 2004
    Posts
    15
    I have tried;

    Function Main()

    SET IDENTITY_INSERT ON
    DTSDestination("ID")
    SET IDENTITY_INSERT OFF

    DTSDestination("UserID") = ("2")
    DTSDestination("FirstName") = DTSSource("FirstName")
    DTSDestination("Surname") = DTSSource("Surname")
    DTSDestination("StudAdminID") = DTSSource("StudentID")
    DTSDestination("Password") = DTSSource("Password")
    DTSDestination("SessionYear") = DTSSource("Session/Year")

    Main = DTSTransformStat_OK
    End Function

    Returns an error, needs an '='.

    Thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •