Home >> FAQs/Tutorials >> SQL Server FAQ

SQL Server FAQ - INT and NUMBERIC - Exact Numeric Data Types

By: FYIcenter.com

(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
GO

(Continued on next topic...)

  1. What Is SQL Language?
  2. What Is Transact-SQL Language?
  3. What Is a Transact-SQL Statement?
  4. How To Start and End Transact-SQL Statements?
  5. How To Enter Comments in Transact-SQL Statements?
  6. What Is a Transact-SQL Statement Batch?
  7. What Happens to a Statement Batch If There Is a Compilation Error?
  8. How To Use GO Command in "sqlcmd"?
  9. How To Create User Messages with PRINT Statements?
  10. How Many Categories of Data Types Used by SQL Server?
  11. What Are Exact Numeric Data Types?
  12. What Are Approximate Numeric Data Types?
  13. What Are Date and Time Data Types?
  14. What Are Character String Data Types?
  15. What Are Unicode Character String Data Types?
  16. What Are Binary String Data Types?
  17. What Are the Differences between CHAR and NCHAR?
  18. What Are the Differences between CHAR and VARCHAR?
  19. What Are the Differences between DECIMAL and FLOAT?

Related Articles:

More...


Other Tutorials/FAQs:

More...


Related Resources:

More...


Selected Jobs:

More...