问题
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.
回答1:
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
来源:https://stackoverflow.com/questions/5593623/reset-pk-auto-increment-column