由於在SQL-SERVER中,自增列屬性不能直接修改,但可以通過以下方式變向實現
1、如果僅僅是指定值插入,可用以下語句,臨時取消
SET IDENTITY_INSERT TableName ON INSERT INTO tableName(xx,xx) values(xx,xx) SET IDENTITY_INSERT TableName OFF
2、新增一列,刪除自增列,修改改列名
alter table a add xxx int update a set xxx=id alter table a drop column id exec sp_rename 'xxx', 'id', 'column'
3、通過修改系統關於該表的列屬性,該方法使用不當將可能引起其它不可預料的錯誤
sp_configure 'allow update',1 reconfigure with override go update syscolumns set colstat=0 where colstat=1 and id=object_id('tablename') go sp_configure 'allow update',0 reconfigure with override