设计修改MSSQLServer 数据库表 字段 报错 ALTER TABLE only allows columns ... 对无法重新创建的表进行了更改...

一、现象:

设计修改MSSQLServer 数据库表 字段时,报错如下:


“T_Operator”表

- 无法修改表。
ALTER TABLE only allows columns to be added that can contain nulls, or have a DEFAULT definition specified, or the column being added is an identity or timestamp column, or alternatively if none of the previous conditions are satisfied the table must be empty to allow addition of this column. Column 'IsDeleted' cannot be added to non-empty table 'T_Operator' because it does not satisfy these conditions.




二、原因:

由于该数据表中存有数据,且新增字段不能设置不允许为空造成。



三、解决:

1、先选择“允许Null值”。


2、手动填写新增字段的值


3、将新增字段改成“不允许为空”


四、如果是SQLServer 2014 ,将会提示“对无法重新创建的表进行了更改...”  ,则进行以下操作:


工具——选项——设计器——表设计器和数据库设计器——阻止保存要求重新创建表的更改





版权声明:本文为ziliang100原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。