Indentity Columns - increment value

  • Hey everyone.

    Here is an interesting one. How would you go about altering the increment value of an identity column and have it affect all prior data with the new increment value?

    So you have the following

    Col1 (identity column)

    1

    2

    3

    4

    and it should be replace

    col1

    1

    4

    7

    10

    Thanks,

    Fraggle

  • I would create another, identical table with the new identity increment value, insert into it from the original table, drop the original table and rename the new one.

    Greg

  • There is no direct way to do this.

    If you must physically re-align the identity values rebuild the table as suggested above.

    if you just need the values to be incremental on a query, take a look at the new row_Number() function, or Rank() Functions

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

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