Today, I'm continuing the discussion on the variety of data types supported by SQL Server. Last time I mentioned exact decimal numbers, but there are also inexact (or approximate) decimal numbers. Here are the available types:
These two data types float and real are approximate data types.
You probably realize that in decimal, there are values we can't store exactly like 1/3. No matter how many 3's we write when we write 0.33333333, we are still never going to have the exact value.
And the same happens in binary, just with different numbers. A simple example is ten cents. A value of 0.1 can't be stored exactly in float or real.
For that reason, they should only rarely ever appear in business applications. Using them for things like amounts of money is a really common newbie mistake when working with SQL Server.
There are places where float and real make sense but they are mostly in scientific and technical applications.
It's worth your while becoming proficient in SQL. If you'd like to learn a lot about T-SQL in a hurry, our Writing T-SQL Queries for SQL Server course is online, on-demand, and low cost.