在不动用sp_configure的情况下,如何 =》去掉列的自增长,并保留原数据

 异常处理汇总-数据库系列  http://www.cnblogs.com/dunitian/p/4522990.html

后期博客首发:http://dnt.dkill.net/Article/Detail/317

应用场景:权限不够(只是某个用户,权限很低,不能使用sp_configure

执行

附录:

update BackupShopMenu set TempId=MId
alter table BackupShopMenu drop column MId
exec sp_rename 'BackupShopMenu.TempId', 'MId', 'column'
alter table BackupShopMenu alter column MId int not null --如果你的字段是可以为null就不需要这段了

网上参考:

如何用sql语句去掉列的自增长(identity) 

**无法通过alter把现有自增字段改为非自增 
比如alter   table   a   alter   id   int,自增属性不会去掉 
通过修改系统表可以做到(此法可能有不可预知的结果,慎之...) 
sp_configure   'allow   updates ',   1 
GO 
reconfigure   with   override 
GO 
update   syscolumns   set   colstat   =   colstat   &   0x0000   
where     id=object_id( '表名 ')   and   name= '字段名 ' 
GO 
sp_configure   'allow   updates ',   0 

--------------------------------------------- 
--折中的办法 
alter   table   a   add   xxx   int 
update   a   set   xxx=id 
alter   table   a   drop   column   id 
exec   sp_rename   'xxx ',   'id ',   'column ' 
---------------------------------------------

原文地址:https://www.cnblogs.com/dunitian/p/5373361.html