Partition--使用分区切换来增加修改列的自增属性
使用分区来将非自增表改为自增表
---------------------------------------------------创建测试表TestTable001和TestTable002CREATE TABLE TestTable001 ( ID INT PRIMARY KEY, C1 VARCHAR(200) )GOCREATE TABLE TestTable002 ( ID INT IDENTITY PRIMARY KEY, C1 VARCHAR(200) )GO--向测试表TestTable001插入数据INSERT INTO TestTable001 SELECT ROW_NUMBER() OVER (ORDER BY object_id) AS RID, name FROM SYS.all_objectsGO---------------------------------------------------将分区表切换来将TestTable001换入到TestTable002中ALTER TABLE TestTable001 SWITCH PARTITION 1 TO TestTable002--使用RESEED重置自增值DBCC CHECKIDENT('TestTable002',RESEED)--查看当前表中自增值SELECT IDENT_CURRENT('TestTable002')---------------------------------------------------插入测试INSERT INTO TestTable002(C1)SELECT 'Test'--查看上一次插入的自增IDSELECT @@IDENTITY
--=========================================
相关文章