MSSQL 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

----允许对系统表进行更新
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

相关文章:

  • 2022-12-23
  • 2022-01-05
  • 2022-12-23
  • 2021-10-10
  • 2022-12-23
  • 2022-02-08
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-01-23
  • 2021-12-21
  • 2021-10-10
  • 2019-02-22
  • 2022-12-23
  • 2022-12-23
  • 2022-02-02
相关资源
相似解决方案