Friday, July 18, 2008

SQL Server 2005 - Resetting autoincrementing table id

To reset the auto-incrementing id on a table use the following syntax

declare @newseed int
select @newseed = max(columnName) from tableName
dbcc checkident(tableName, RESEED, @newseed)

Of course substituting your table name for tableName and the id column's name for columnName

No comments: