Mega Code Archive

 
Categories / MSSQL Tutorial / System Settings
 

Syntax for Reseeding the IDENTITY Value with a New Explicit Value

DBCC CHECKIDENT ('table_name' , RESEED, new_reseed_value) Reseeding the IDENTITY Value of MyTable with a New Explicit Value 7> CREATE TABLE MyTable ( 8>  key_col int NOT NULL IDENTITY (1,1), 9>  abc     char(1) NOT NULL 10> ) 11> INSERT INTO MyTable VALUES ('a') 12> INSERT INTO MyTable VALUES ('b') 13> INSERT INTO MyTable VALUES ('c') 14> SELECT * FROM MyTable ORDER BY key_col 15> GO (1 rows affected) (1 rows affected) (1 rows affected) key_col     abc ----------- ---           1 a           2 b           3 c (3 rows affected) 1> 2> DBCC CHECKIDENT ('MyTable', RESEED, 50) 3> 4> drop table MyTable 5> GO Checking identity information: current identity value '3', current column value '50'. DBCC execution completed. If DBCC printed error messages, contact your system administrator. 1>