Modify SqlServer auto-increment identity column

## 1. Change the current value of an auto increment

#### View a table in an auto-increment the current value:

DBCC   CHECKIDENT   (TableName)

#### to modify a table auto-increment the current value:

DBCC   CHECKIDENT   (TableName,   RESEED,   value)
RESEED不是列名,固定写法。

#### For example, I want Division table from the current value to be added to 30 can use the following command
DBCC CHECKIDENT (Division, RESEED, 30)
and then
DBCC CHECKIDENT (Division)
you can see the display of the current value is 30

## 2.SQL forcibly inserted identification data column

set identity_insert table on - Turns
insert into table (automatic growth ID column, ......) values (100, ......)
set identity_insert table off - Close
example:
set identity_insert tblClass on - Turns

insert into tblClass (cid,cname) values (100,‘java班’)

set identity_insert tblClass off - close

## 3. The following error occurs, for example,
Cannot update identity column

Published 12 original articles · won praise 6 · views 671

Guess you like

Origin blog.csdn.net/u011363395/article/details/104414698