Home >> FAQs/Tutorials >> SQL Server FAQ
SQL Server FAQ - INT and NUMBERIC - Exact Numeric Data Types
(Continued from previous topic...)
What Are Exact Numeric Data Types?
Exact numeric data types are used to store numeric values with exact precisions and scales.
SQL Server 2005 supports the following exact numeric data types:
- BIGINT - 8-byte integers in the range of -2^63 (-9,223,372,036,854,775,808) to 2^63-1 (9,223,372,036,854,775,807).
- INT - 4-byte integers in the range of -2^31 (-2,147,483,648) to 2^31-1 (2,147,483,647).
- SMALLINT - 2-byte integers in the range of -2^15 (-32,768) to 2^15-1 (32,767).
- TINYINT - 1-byte integers in the range of 0 to 255.
- BIT - 1-bit integers with 2 values: 0 and 1.
- DECIMAL - Decimal numbers with a fixed precision p and a fixed scale s defined as DECIMAL(p,s).
DECIMAL values are in the range of -10^38+1 to 10^38-1. DECIMAL has a synonym of DEC.
- NUMERIC - Same as DECIMAL.
- MONEY - Currency values stored in 8 bytes in the range of -922,337,203,685,477.5808 to 922,337,203,685,477.5807
- SMALLMONEY - Currency values stored in 4 bytes in the range of - 214,748.3648 to 214,748.3647
Here are some good examples of exact numeric values:
PRINT 372036854775808; -- BIGINT
PRINT 147483648; -- INT
PRINT 2768; -- SMALLINT
PRINT 250; -- TINYINT
PRINT 1; -- BIT
PRINT 12748.3648; -- DECIMAL(9,2)
PRINT 337203685477.58; -- MONEY
PRINT 748.36; -- SMALLMONEY
(Continued on next topic...)
- What Is SQL Language?
- What Is Transact-SQL Language?
- What Is a Transact-SQL Statement?
- How To Start and End Transact-SQL Statements?
- How To Enter Comments in Transact-SQL Statements?
- What Is a Transact-SQL Statement Batch?
- What Happens to a Statement Batch If There Is a Compilation Error?
- How To Use GO Command in "sqlcmd"?
- How To Create User Messages with PRINT Statements?
- How Many Categories of Data Types Used by SQL Server?
- What Are Exact Numeric Data Types?
- What Are Approximate Numeric Data Types?
- What Are Date and Time Data Types?
- What Are Character String Data Types?
- What Are Unicode Character String Data Types?
- What Are Binary String Data Types?
- What Are the Differences between CHAR and NCHAR?
- What Are the Differences between CHAR and VARCHAR?
- What Are the Differences between DECIMAL and FLOAT?