decimal(10, 10)
表示所有小數位,小數點左邊沒有數字!
在這裏看到:http://msdn.microsoft.com/en-us/library/aa258832(SQL.80).aspx_
decimal[(p[, s])]
p (precision) Specifies the maximum total number of decimal digits that can be stored, both to the left and to the right of the decimal point. The precision must be a value from 1 through the maximum precision. The maximum precision is 38. The default precision is 18.
s (scale) Specifies the maximum number of decimal digits that can be stored to the right of the decimal point. Scale must be a value from 0 through p. Scale can be specified only if precision is specified. The default scale is 0; therefore, 0 <= s <= p. Maximum storage sizes vary, based on the precision.
decimal(11,10)
給你1位小數和10到右邊的左邊,所以整數1,現在適合!
編輯
使用時:decimal(p,s)
,認爲p
有多少總位數(無論左或小數點右邊)要存儲,並s
有多少的那些p
數字應該在小數點右邊。
DECIMAL(10,5)= 12345.12345
DECIMAL(10,2)= 12345678.12
DECIMAL(10,10)= .1234567891
DECIMAL(11,10)= 1.1234567891
我還是很困惑。它表示比例尺是「*最大*小數點右邊可存儲的小數位數」 - 並非必須爲10. – froadie 2010-04-13 13:53:19
是的,但並不意味着它是小數點的滑動點。其含義是,如果您向右側提供少於10位數字,則其餘爲零。 – Joe 2010-04-13 13:58:13
@Joe,我不確定你想說什麼,但是如果你運行'declare @x decimal(5,2); set @ x = 1.123456789;選擇@x; set @ x = 1; select @ x'你會得到'1.12'和'1.00'。一旦聲明小數點後,小數點左側和右側的數字數是固定的,則不會出現小數點的滑動。 – 2010-04-13 14:05:58