Sunday, July 13, 2008

AutoNumber Reset in SQL 2005

This post is pretty much just a note for myself, but it might help someone too.  When appending rows from an Access Database table to a SQL Server table of the same structure, sometimes SQL will not retain the ID's for AutoNumber fields.  This can be a big problem for our ParaPlan application.  In Access you can compact and repair to reset your autonumber fields back to 0 or 1 obviously.  However, I never really figured out how to do that in SQL 05 until now.

To clear a table's records and reset the autonumber in SQL 05, just use the following syntax in a query on SQL db:

"truncate table dbo.drivers"

Post a Comment