Reset PK auto increment column

11,715

You'll need the DBCC CHECKIDENT command with the reseed option, not sure I buy that it will improve SEO though.

DBCC CHECKIDENT ("dbo.Table", RESEED, 0); --next id will be 1

http://msdn.microsoft.com/en-us/library/ms176057.aspx

Share:
11,715
Tom Gullen
Author by

Tom Gullen

Me Web developer. Website http://www.scirra.com

Updated on June 04, 2022

Comments

  • Tom Gullen
    Tom Gullen almost 2 years

    I've been importing thousands of records multiple times in an effort to get the import running perfectly.

    As a result, now when I do the live import before release, the ID columns for the auto increment column are on around 300,000.

    Is there any easy way to 'reset' this once I have deleted all the data from these tables? I only want to for SEO reasons, the URL:

    Forum/1/Post
    Forum/35/Post
    Forum/5600/Post
    

    Looks a lot nicer and more concise (therefore more clickable in results) than

    Forum/300124/Post
    Forum/370321/Post
    Forum/450111/Post
    

    I'd rather not delete the column and reinsert the column as it would ruin all relationships and mean I'd have to refresh all my data context diagrams etc.