reseting an autonumber

  • another quick one:

    how do i reset an autonumber field in the sql server ?

    it's a temp table and every time it's filled with almost 100,000 recods and then deletes them.

    thanks,

    Gilad

  • Here is an example from Books On Line that resets the number to 30 :

    USE pubs
    GO
    DBCC CHECKIDENT (jobs, RESEED, 30)
    GO

     
    Hope this helps,
    Kathi

    Aunt Kathi Data Platform MVP
    Author of Expert T-SQL Window Functions
    Simple-Talk Editor

  • Thanks kathy, it helped.

  • IF it is a #temp table then on DROP/RECREATE it will reset the IDENTITY to 1

    IF is is a "temp" table meaing it is in existence all the time i.e. a "REAL" table then TRUNCATE TABLE will reset the INDENTITY to 1



    Good Hunting!

    AJ Ahrens


    webmaster@kritter.net

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

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