updating SYS.IDENTITY_COLUMNS in sql server 2008 r2

  • Hi,

    I have a table with one of its col as auto-increment. The max value set is 1500. when the table reached 1234 records, the next few records has been added directly to the table without insert command. So now the last id in the table is 1300. but when I try insert command its taking the last value from SYS.IDENTITY_COLUMNS and trying to add the next id ie 1235 which is already present giving duplicate value error. Is there anyway where I can start the id from 1301 or update the SYS.IDENTITY_COLUMNS last_value to 1300?

    Thanks in Advance,

  • shobha.aradhya (6/26/2012)


    Hi,

    I have a table with one of its col as auto-increment. The max value set is 1500. when the table reached 1234 records, the next few records has been added directly to the table without insert command. So now the last id in the table is 1300. but when I try insert command its taking the last value from SYS.IDENTITY_COLUMNS and trying to add the next id ie 1235 which is already present giving duplicate value error. Is there anyway where I can start the id from 1301 or update the SYS.IDENTITY_COLUMNS last_value to 1300?

    Thanks in Advance,

    Hi Shobha,

    Try out 'DBCC CHECKIDENT' to reset the identity.

    --rhythmk
    ------------------------------------------------------------------
    To post your question use below link

    https://www.sqlservercentral.com/articles/forum-etiquette-how-to-post-datacode-on-a-forum-to-get-the-best-help
    🙂

  • Use below command

    DBCC CHECKIDENT ("TableName",RESEED, 1300);

    --rhythmk
    ------------------------------------------------------------------
    To post your question use below link

    https://www.sqlservercentral.com/articles/forum-etiquette-how-to-post-datacode-on-a-forum-to-get-the-best-help
    🙂

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

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