truncate table tablename
--truncate方式也可以重置自增字段--重置表的自增字段,保留数据
DBCC CHECKIDENT (tablename,reseed,0)
-- 设置允许显式插入自增列
SET IDENTITY_INSERT tablename ON
-- 当然插入完毕记得要设置不允许显式插入自增列
SET IDENTITY_INSERT tablename OFF
1、如果仅仅是指定值插入,可用以下语句,临时取消
SET IDENTITY_INSERT TableName ONINSERT INTO tableName(xx,xx) values(xx,xx)SET IDENTITY_INSERT TableName OFF
2、新增一列,删除自增列,修改改列名
alter table a add xxx intupdate a set xxx=idalter table a drop column idexec sp_rename 'xxx', 'id', 'column'
3、通过修改系统关于该表的列属性,该方法使用不当将可能引起其它不可预料的错误
sp_configure 'allow update',1reconfigure with overridegoupdate syscolumns set colstat=0 where colstat=1 and id=object_id('tablename')gosp_configure 'allow update',0reconfigure with override