Exact numeric data consists of numeric data with accuracy preserved to the least-significant digit. SQL Server 6.0 supports two exact numeric datatypes: decimal and numeric. Both decimal and numeric data can contain an integer component to the left of the decimal point and a fractional component to the right of the decimal point. Exact numeric datatypes are different from the approximate numeric datatypes float and real, which cannot store all decimal numbers with complete accuracy. The decimal and numeric datatypes are identical in the SQL Server 6.0 implementation. Both are provided for ANSI compatibility.
These are the exact numeric datatypes:
Precision | Storage bytes |
---|---|
1 - 2 | 2 |
3 -4 | 3 |
5-7 | 4 |
8-9 | 5 |
10-12 | 6 |
13-14 | 7 |
15-16 | 8 |
17-19 | 9 |
20-21 | 10 |
22-24 | 11 |
25-26 | 12 |
27-28 | 13 |
29-31 | 14 |
32-33 | 15 |
34-36 | 16 |
37-38 | 17 |
Precision (p) specifies the maximum total number of decimal digits that can be stored, both to the left and to the right of the decimal point. Scale (s) specifies the maximum number of decimal digits that can be stored to the right of the decimal point, and it must be less than or equal to the precision.
Specify the precision with p, which must be a value from 1 through the maximum precision, and the scale with s, which must be a value from 0 through p. SQL Server normally supports a maximum precision of 28 digits for compatibility with limits of various front ends, such as Microsoft Visual Basic. However, if a precision greater than 28 is needed, use the /p parameter with SQLSERVR.EXE. For more information on running SQLSERVR.EXE, see the Utilities and Executables topic. If you do not specify the precision, SQL Server uses a default precision of 18. If you do not specify the scale, SQL Server uses a default scale of 0.