SEED-y problem

  • We have a table "A" in production and its twin "A" in development. The tables are identical (via Sql Compare); both use an identiity field as primary key.

    When we run

    delete from A

    DBCC CHECKIDENT (A, RESEED, 0)

    and add a new record, we find the identity field starts at 1.

    When we run

    delete from B

    DBCC CHECKIDENT (B, RESEED, 0)

    and add a new record, we find the identity field starts at 0.

    Any ideas on this one?

    TIA,

    barkingdog

  • If you just TRUNCATE the tables, no reseeding is necessary... IDENTITY columns will start over.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • Hi,

    Your table B was empty so when you run the following command, the new identity will start with a value of 0

    delete from B

    DBCC CHECKIDENT (B, RESEED, 0)

    When you DBCC CHECKIDENT (tablename, RESEED, 0) and tablename is vergin table, when you insert new record your counter start at 0.

    Check http://blog.sqlauthority.com/2007/03/15/sql-server-dbcc-reseed-table-identity-value-reset-table-identity/

    Regards,

    Ahmed

  • Thanks for your answer.

    Barkingdog

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

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