Reseed an Identity Column

Sometimes identity columns must be reseeded.  A good example is when merging data from a couple of different  data sources.  There is a DBCC command that makes this task easy.

DBCC CHECKIDENT (<table name>, RESEED, <new value>

To find what existing identity column values are, a simple query can be written off the sys.identity_columns system view.
SELECT   OBJECT_NAME(object_id) AS [Table],
[name] AS [column],
seed_value,
last_value
FROM sys.identity_columns
ORDER BY 1

 

What did you think of this article?




Trackbacks
  • No trackbacks exist for this entry.
Comments
  • No comments exist for this entry.
Leave a comment

 Enter the above security code (required)

 Name

 Email (will not be published)

 Website

Your comment is 0 characters limited to 3000 characters.