Identity column resetting

  • Hi All,

    I imported some rows from some other table by giving set Identity_insert on command, and droping my Primary Key, but after that i couldnot set my primary key as it's now containing duplicates.

    Is there any way by which these duplicated identity rows can be reseeded, so that I can create the primary key again with Identity.

    Thanks in advance

  • Hi Rahuul,

    what about dropping the field, save, create a new int field and make it primarykey and identity and save again?

    Cheers,

    Frank

    --
    Frank Kalis
    Microsoft SQL Server MVP
    Webmaster: http://www.insidesql.org/blogs
    My blog: http://www.insidesql.org/blogs/frankkalis/[/url]

  • don't remove the pk. delete the rows and reimport them without set identity_insert to give them new values.

    if that's not possible, you can remove the identity (Requires a table rebuild) and then "fix" the data. Once that is done, you could rebuild the table with a new seed value that doesn't create duplicates.

    Steve Jones

    sjones@sqlservercentral.com

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

    http://www.dkranch.net

  • yes identity column can be reset as follows

    DBCC CHECKIDENT (<TableName>, RESEED, <reseed value>)

    AMIT KULSHRESTHA

    SOFTWARE ENGINEER

    NEW DELHI,INDIA


    AMIT KULSHRESTHA
    SOFTWARE ENGINEER
    NEW DELHI,INDIA

  • Hi All,

    Thanks for the all your help, I recreated a field and set the identity column and Primary key, and it is all fine now!!!

    Thanks much!

    quote:


    Hi Rahuul,

    what about dropping the field, save, create a new int field and make it primarykey and identity and save again?

    Cheers,

    Frank


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

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