Wednesday, July 30, 2008

Reseting the increment id back to 1 in SQL

Let's say you have a summary table, and everynight you have either an executable or a sql job that deletes all rows and then inserts new ones. If that table has an increment id column, you may want to reset it back to 1. Here is how you do that. Just replace 'mytable' with the actuall table.

DBCC CHECKIDENT('mytable', RESEED, 0);

No comments: