Data Modeling: Don't use money for storing money in SQL Server
I know that SQL Server has a number of data types that look like they could be used for storing amounts of money. Developers go looking for data types that have a decimal point in them, and there are a few:
Float - this one seems to get picked by people from a Java background. And it’s pretty much never the right choice. It doesn’t store values exactly because it’s an approximation. Just like we have numbers in decimal that we can’t write exactly (like 1/3 as a decimal is 0.33333 and so on), there are numbers in binary that we can’t store exactly. And that includes numbers like 0.1 (yes, ten cents). So using this data type for money is usually a newbie mistake, and the same applies to the potentially even more approximate real.
2019-06-18