2017-10-13 119 views
1

將數據從flost移動到小數點(5,2)。最大的價值,我可以找到int現有的數據是94.23,但是當我嘗試轉換爲十進制時,它會拋出錯誤。將浮點數轉換爲十進制時出現錯誤

Arithmetic overflow error converting float to data type numeric. 

我試圖直接複製沒有鑄造,得到了錯誤。所以然後我試着先投:

 CAST(Purity as decimal(5,2)) 

同樣的錯誤。

我注意到也有空值在那裏,所以我嘗試:

ISNULL(CAST(Purity as decimal(5,2)),0) 

同樣的錯誤。

回答

1

您是否在尋找數據庫中最大的值?

select max(Purity) 
from t; 

,並在這Purity確實是一個字符串的情況下,你可能有其他的事情正在進行。因此,您可以嘗試:

select max(convert(purity, 18, 6)) -- or something like this 
from t; 
+0

select max()發現值爲9845(無小數),所以存在我的問題。謝謝。 – BattlFrog

相關問題