Thursday, January 3, 2008

Reindex, or Reseed your SQL Tables

If you've erased all the data in a table, and insert a new record, the first record ID will not be 1, or whatever the starting index number is that you required when setting up the table. To reset, reindex, or reseed these numbers and start at 1 again execute the following SQL:

DBCC CHECKIDENT (yourtable, reseed, 0)


Where 'yourtable' is the table you're reindexing.