Thursday, December 2, 2010

Reseed a SQL Server identity column

Checking and reseeding For instance, if you copy all the table’s records to an archive table and then delete all the records in the source table, you might want to reseed the source table’s identity column, so you can control the sequence. Use T-SQL’s DBCC CHECKIDENT as follows to reseed an identity column:

DBCC CHECKIDENT

(

  tablename

  [, [NORESEED | RESEED [, newreseedvalue]]]

)

[WITH NO_INFOMSGS]

No comments:

Post a Comment