注册 登录
编程论坛 SQL Server论坛

看不出啥问题,帮忙看看,请指教!

schanrong 发布于 2008-02-23 21:21, 1077 次点击
计算字段语句:
create table 商品表
  ( 商品名 varchar(20)  not null,
    单价  money  not null,
     数量 float not null,
      折扣 decimal(3,2) not null,
    销售金额as单价*数量*(1-折扣)
   )
提示:  服务器: 消息 170,级别 15,状态 1,行 6
       第 6 行: '*' 附近有语法错误。
2 回复
#2
acupoflife2008-02-26 15:04
as 前后空格
#3
provoke2008-02-26 23:59
基表中不要计算列:
create table 商品
  ( 商品名 varchar(20)  not null,
    单价  money  not null,
    数量 float not null,
    折扣 decimal(3,2) not null
   )
再创建一个视图,把计算列添加到视图中来:
create view 商品表 as
select 商品.*,销售金额=单价*数量*(1-折扣)
from 商品
1