SQL Server修改標識列方法(備忘)

2021-09-21 02:50:35 字數 560 閱讀 1428

原文:

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

SQL Server手工插入標識列

如果我們在標識列中插入值,例如 insert member id,username values 10,admin 則在查詢分析器裡面會返回錯誤資訊 引用內容 伺服器 訊息 544,級別 16,狀態 1,行 1 當 identity insert 設定為 off 時,不能向表 member 中的標識...

SQL SERVER重置自動編號列 標識列

兩種方法 一種是用truncate truncate table name 可以刪除表內所有值並重置標識值 二是用dbcc checkident dbcc checkident table name reseed,new reseed value 如dbcc checkident bc pos re...

SQL SERVER重置自動編號列 標識列

兩種方法 一種是用truncate truncate table name 可以刪除表內所有值並重置標識值 二是用dbcc checkident dbcc checkident table name reseed,new reseed value 如dbcc checkident bc pos re...