reseed table

  • I want to reseed an indentity column starting with 0 instead of 1 (as it is currently). But I don't want to change any of the identity column values. In other words, I just want to add this one row with zero and otherwise leave the table untouched. How can I do that?

    Sam

  • with set identity insert

    * a thread working with identity*

    http://www.sqlservercentral.com/forums/shwmessage.aspx?forumid=8&messageid=265998

  • Do:

    <code>

    SET IDENTITY_INSERT MyTable ON

    GO

    INSERT INTO MyTable (IdCol, Col1, Col2) VALUES (0, 'value1', 'value2')

    GO

    SET IDENTITY_INSERT MyTable OFF

    GO

    </code>

    You probably don't want to reseed the table completly, as this will end up with identity violations as the identity column counts up and eventually runs into existing ID's.

  • Thanks. That did it.

    Sam

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

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