Are you sure that is how you want to get your percentage? Should you move your *100.00
after the division like this?
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;
Also, make sure your @CurrentPatchDeployPercentage
data type can support the highest number of @LastMonthDeployCount *100.00
for when @TotalMachines = 0
and is changed to null
and then changed to 1
.
Decimal/Numeric Data Type - MSDN
Precision Storage bytes
--------- --------------
1 - 9 5
10-19 9
20-28 13
29-38 17