SQL server 2000修改列的约束

来源:百度知道 编辑:UC知道 时间:2024/06/06 06:00:17
use 书库
alter table 购买信息
alter column 定价 smallmoney not null constraint 定价_default default 0.00
以上是代码,但提示是“在关键字 'constraint' 附近有语法错误。”为什么,请指教,谢谢!!!

应该是需要将这个两个分开来写,
一个是用来修改字段类型的,
一个是用来给字段设置默认值的约束,
因此可以改成如下:
use 书库
go
alter table 购买信息
add constraint 定价_default default 0.00
go

alter table 购买信息 alter column 定价smallmoney not null
go
呵呵,希望能有帮助,^_^

alter table 购买信息
add constraint 定价_default default 0.00

alter table 购买信息 alter column 定价smallmoney not null
应该是差个 add 吧~!

多了个alter吧 column前面的alter不用的吧