SQL Server rounding Error, Giving different values

前端 未结 2 498
夕颜
夕颜 2020-12-11 09:37

I have a Stored Procedure that does a lots of calculation, stores the results in several temporary table. Finally calculating the sum and rounding to two decimal and stores

2条回答
  •  抹茶落季
    2020-12-11 09:55

    This is because you are using float database type.

    Float should not be used to represent values that require precision, since they are stored as approximations, different manipulations can give you different results.

    In sql server you can use decimal and numeric data types for numerical precision: http://msdn.microsoft.com/en-us/library/ms187746.aspx

提交回复
热议问题