Results 1 to 1 of 1
  1. #1
    Join Date
    Nov 2011

    Unanswered: Update statement - Auto increment

    Would like to know if DB2 has a equivalent for a update trick in MS SQl server
    that can auto increment a column like serial no.
    The statement is:

    DECLARE @counter int
    SET @counter = 0
    UPDATE tablename
    SET @counter = slno = @counter + 1

    slno is the column name here

    This will set the value for the column 'counter' as 1,2,3 for each row.
    Tried the above in DB2, but gives syntax error for two "=" symbols.
    Iam on DB2 Z/os v10.
    Last edited by techday; 03-28-12 at 08:15.

Posting Permissions

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