数値データ型に変換する数値の算術オーバーフローエラー、あなたはそれはあなたがあなたの割合を取得したい方法ですか?このような部門の後に*100.00
を移動する必要がありますか?
rextester:http://rextester.com/NNOEH44668
declare @LastMonthDeployCount numeric(7,2) = 10.00;
declare @TotalMachines numeric (7,2) = 100.00;
declare @CurrentPatchDeployPercentage numeric(9,2);
set @CurrentPatchDeployPercentage =
convert(numeric(5,2),
(isnull(@LastMonthDeployCount, 0)
/
isnull(nullif(@TotalMachines, 0), 1.0)
) * 100.00
);
select @CurrentPatchDeployPercentage;
また、あなたの@CurrentPatchDeployPercentage
データ型がとき@TotalMachines = 0
ため@LastMonthDeployCount *100.00
の最大数をサポートすることができますし、null
に変更し、その後1
に変更されていることを確認します。
Decimal/Numeric Data Type - MSDN
Precision Storage bytes
--------- --------------
1 - 9 5
10-19 9
20-28 13
29-38 17
(5,2)の数値5 2分数の意味、5つの総桁数を可能にする - 左の2 = 3の合計桁。計算結果が999.99を超え、エラーが発生します。 numeric() –
のサイズを大きくする数値(5,2)を数値(x、y)に増やすことはできますか?x、yは指定した値よりも相対的に高くなります – balaji
[SQL Serverがスローする理由intをデータ型数値に変換する?](http://stackoverflow.com/questions/2059134/why-sql-server-throws-arithmetic-overflow-error-converting-int-to-data-type-nume) – Tanner