2011-08-29 35 views
3

從Visual Studio 2010中編輯字段時,我將該值更改爲0,01十進制類型的SQL列將數字0,01舍入爲0

enter image description here

當comminiting通過循環到行結束的變化,它變成了0。

enter image description here

任何想法,爲什麼出現這種情況?我需要它來保存0,01作爲值。 RegularCost字段會發生同樣的問題。我需要保存299,45這樣的東西,並且它會四捨五入。

這裏的SQL:

create table Auction 
(
AuctionId int primary key identity(1,1), 
ProductId int foreign key references Product(ProductId), 
AuctionCategoryId int foreign key references AuctionCategory(AuctionCategoryId), 
SerialNumber nvarchar(1024), 
StartTime datetime, 
EndTime datetime, 
AvailableForBuyNow bit, 
BuyNowCost decimal, 
LanceCost decimal, 
ClosingLanceCount int, 
WonByUser int, 
RegularCost decimal 
) 

回答

1

嘗試指定precision and scale像這樣

LanceCost decimal(10,2) 

或使用money類型:

LanceCost money 
+0

現貨應避免貨幣類型的時間99.99999%,雖然。 http://stackoverflow.com/questions/582797/should-you-choose-the-money-or-decimalx-y-datatypes-in-sql-server – Kenneth