There are several different types of numeric values in SQL Server, one of which is: exact type and approximate type . The approximate type actually has only two data types: float and real.
In our database design, if the design to need to store non-shaping values, many times we will be wondering exactly which of the following data types are needed:
- Float
- Real
- Decimal
- Numeric
It's really simple to say, but there are only two types of the above 4 types:
1) Float & Real
They are all numeric types that represent floating-point numbers, and are an approximate numeric representation, and Real is a special form of float.
The syntax of float is as follows:
Float (n): N is the number of bits (expressed in scientific notation) used to store the mantissa of the float value, which determines the precision and storage size of N. n is between 1 and 53 and defaults to 53
Value of N |
Precision |
Storage size |
1–24 |
7-digit number |
4 bytes |
25-53 |
15-digit number |
8 bytes |
Real is equivalent to float (24)
2) Decimal & Numeric
Numeric is functionally equivalent to decimal, so we only talk about decimal. Decimal represents an exact numeric value with fixed precision and scale, and its syntax is as follows:
Decimal (P [, S])
P represents precision, that is, the total number of decimal digits that can be stored, including the number of digits to the left and right of the decimal point, which can make any value between 1 and 38, which defaults to 18
s represents the maximum number of decimal digits to the right of the decimal point
Tsql-decimal, Numeric, Float & Real