问题描述:
在为已存在的表中新增了ActivateJDCard字段,Int类型,并为其设置默认值
alter table financial_plan add ActivateJDCard int default 0
当执行
alter table financial_plan drop column ActivateJDCard
后发现并不能直接删除,会报错误
问题原因:
是因为不能直接删除有默认值的字段
解决方案:
select * from sysobjects where object_name(parent_obj)='表名'
先查找默认值字段约束名称,再进行删除这个字段的约束
alter table [表名] drop constraint [默认值名]
然后就可以用
alter table financial_plan drop column ActivateJDCard
进行删除了