2009-02-28 60 views
1

我有問題,在設置公式特別是field.I使用sql數據庫已添加 - >添加新項目 - > sql數據庫。我有以下字段的訂單表 ordernum主鍵 訂購日期SMALLDATETIME, custemail VARCHAR(50), 小計金錢, 銷售稅錢, 航運錢, 總AS(小計+銷售稅+運費)問題與設置公式在列

如何設置這個總公式,也沒有提到數據類型總場。

感謝, 哈比卜

+0

在一個DB爲什麼或者爲什麼不是已經計算領域的一個很好的,如果有點長,討論:http://forums.whirlpool.net.au/forum-replies -archive.cfm/536304.html – bernie 2009-02-28 19:38:57

回答

1

這個例子應該說明你正在尋找實現的目標。

create table #table 
    (
     ordernum int identity(1,1) primary key, 
     orderdate smalldatetime, 
     custemail varchar(50), 
     subtotal money, 
     salestax money, 
     shipping money, 
     total AS(subtotal+salestax+shipping) 
    ) 

    insert into #table 
    (
     orderdate, 
     custemail, 
     subtotal, 
     salestax, 
     shipping 
    ) 
    select 
     getDate(), 
     '[email protected]', 
     1.00, 
     1.00, 
     1.00 

    select * from #table 

    drop table #table 

歡呼聲中,約翰