October 26, 2009

Sql Server: Reset identity Value.

dbcc checkident([tableName],reseed/NORESEED,[Reset_Start_Vaue])

Parameter Description :

  1. NORESEED Returns the current identity value and the current maximum value of the identity column, without reseeding. These values are usually (and should be) the same.
  2. RESEED Changes the current identity value, using the maximum value in the identity column, if the current identity value is less than the maximum identity value stored in the identity column.
  3. newreseedvalue Specifies the new seed value when reseeding. If the table is empty, the first identity value (after executing DBCC CHECKIDENT) will equal newreseedvalue. If the table contains data, the next identity value will equal newreseedvalue + the current increment value (the default is 1). This behavior is new to SQL Server 2005 (and remains in 2008). SQL Server 2000 always increments the seed value.
  4. WITH NO INFOMSGS Suppresses all informational messages.

    Example:

    dbcc checkident('tblDetails',reseed,0)

No comments:

Post a Comment