有關SQL server 2000!!

2007-04-13 7:57 pm
我想問
我用SQL server 2000整左個database做功課,
(1)假設有個field叫price,如果我想個data出到小數,個data type係唔係用money or decimal??
(2) 如果我用money做data type,有無可能將小數位改為小數後2個位??因為入面default 左做4個位,改唔到!!
(3) 如上面一樣,有個叫做monetary資料,我想問點用?可唔可以print出黎既資料有dollar sign and 小數後2個位?

問題太多,希望有人解答到我!!!!!!! thx

回答 (1)

2007-04-20 12:37 pm
✔ 最佳答案
(1) I suggest using money. Decimal does not round value. If you enter 12.349, the value becomes 12.34 instead of 12.35.

(2) (3) It depends on how you output the data. If you are using SQL statements, you can use the ROUND function.

select ROUND(price,2) from mytable

(3)
select '$'+CAST(Round(price,2) AS varchar) from mytable


收錄日期: 2021-04-25 20:32:21
原文連結 [永久失效]:
https://hk.answers.yahoo.com/question/index?qid=20070413000051KK01628

檢視 Wayback Machine 備份