1. 程式人生 > >SQL Server修改標識列方法(轉)

SQL Server修改標識列方法(轉)

----允許對系統表進行更新
exec sp_configure 'allow updates',1
reconfigure with override
GO

----取消標識列標記
update syscolumns set colstat = 0 where id = object_id('tablename') and colstat = 1
GO

--插入id=8001-8003的行
...

----恢復標識列標記
update syscolumns set colstat = 1 where id = object_id('tablename') and name = '標識列名稱'

----重新設定標識的起始值
DBCC CHECKIDENT (表名稱, RESEED, 10003)

----禁止對系統表進行更新
exec sp_configure 'allow updates',0
reconfigure with override