这是什么sql错误use tsing1
create table tsing1.dbo.stud_score
(
year int not null,
stud_id int not null,
math_score numeric(4,1)check(math_score>=0and math_score<=100),
engl_score numeric(4,1)check(engl_score>=0and engl_scroe<=100),
comp_score numeric(4,1)check(comp_score>=0and comp_scroe<=100),
chem_score numeric(4,1)check(chem_score>=0and chem_scroe<=100),
phys_score numeric(4,1)check(phys_score>=0and phys_scroe<=100),
constraint pk_chk primary key (year,stud_id))
结果显示如下:
服务器: 消息 8141,级别 16,状态 1,行 2
列 CHECK 约束(属于列 "engl_score")引用了另一列,表 "tsing1.dbo.stud_score"。
服务器: 消息 8141,级别 16,状态 1,行 2
列 CHECK 约束(属于列 "comp_score")引用了另一列,表 "tsing1.dbo.stud_score"。
服务器: 消息 8141,级别 16,状态 1,行 2
列 CHECK 约束(属于列 "chem_score")引用了另一列,表 "tsing1.dbo.stud_score"。
服务器: 消息 8141,级别 16,状态 1,行 2
列 CHECK 约束(属于列 "phys_score")引用了另一列,表 "tsing1.dbo.stud_score"。
服务器: 消息 1759,级别 16,状态 1,行 2
在约束或计算列的定义中指定了无效的列 "engl_scroe"。
服务器: 消息 1750,级别 16,状态 1,行 2
未能创建约束。请参阅前面的错误信息。 改成这样:试试
math_score numeric(4,1) CHECK(math_score BETWEEN 0 AND 100)
我记得CHECK只可以用IN,LIKE,BETWEEN,好像没什么>,<之类的。不错,谢了!
|