Results 1 to 3 of 3

Thread: reset Identity field

  1. #1

    Thread Starter
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    reset Identity field

    Is there a SQL command or something i can do on SQL Server 2000 to reset an ID field to its starting number in a table that has no records?

    I know I can just delete the ID field and redd it, but I am wondering if there is a way to do this without removing and readding the field.

  2. #2
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758

    Re: reset Identity field

    Two ways

    Execute a Truncate Table command or DBCC CheckIdent command.

    DBCC CHECKIDENT - Checks the current identity value for the specified table and, if needed, corrects the identity value.

    Code:
    Syntax
    DBCC CHECKIDENT 
        ( 'table_name' 
            [ , { NORESEED 
                    | { RESEED [ , new_reseed_value ] } 
                } 
            ] 
        )

  3. #3

    Thread Starter
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: reset Identity field

    thanks. I used Truncate Table to do it.. I am just working on a conversion and we have to do lots of test imports... so I don't want the autonumbers getting too high..

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width