DBCC CHECKIDENT (Transact-SQL) Checks the current>
Permissions
Caller must own the schema that contains the table, or be a member of the sysadmin fixed server role, the db_owner fixed database role, or the db_ddladmin fixed database role.
Examples A. Resetting the current> The following example resets the current>AdventureWorks2012 database.
USE AdventureWorks2012;
GO
DBCC CHECKIDENT ('Person.AddressType');
GO B. Reporting the current>
The following example reports the current>AdventureWorks2012 database, and does not correct the>USE AdventureWorks2012;
GO
DBCC CHECKIDENT ('Person.AddressType', NORESEED);
GO C. Forcing the current> The following example forces the current>AddressTypeID column in the AddressType table to a value of 10. Because the table has existing rows, the next row inserted will use 11 as the value, that is, the new current increment value defined for the column value plus 1.
USE AdventureWorks2012;
GO
DBCC CHECKIDENT ('Person.AddressType', RESEED, 10);
GO
https://msdn.microsoft.com/en-IN/library/ms176057.aspx
SQL Server 重置Identity标识列的值(INT爆了)
http://www.cnblogs.com/gaizai/archive/2013/04/23/3038318.html 一、背景
(Figure7:数据记录)
8) 假如我们删除了IdentityId为1000和1001的记录,这个时候继续插入数据,会重新生成1000和10001值吗?效果如Figure10所示(重新覆盖了);
--删除和delete from [Test_Identity] where IdentityId=1000delete from [Test_Identity] where IdentityId=1001
(Figure8:数据记录)
--重置标识值DBCC CHECKIDENT('Test_Identity', RESEED, 996)--隐式插入Id值INSERT INTO [Test_Identity](Name)SELECT 'name6'
(Figure9:数据记录)
三、补充说明
在MySQL中,也有类似Identity的功能:
`IDs` int(11) unsigned NOT NULL AUTO_INCREMENT
在创建表的时候,会有一个选项AUTO_INCREMENT=17422061,直接可以设置起始值,还可以设置步长:
SHOW VARIABLES LIKE 'auto_inc%';
起始值:auto_increment_offset
步长:auto_increment_increment
SET @auto_increment_increment=10;
SELECT LAST_INSERT_ID();