Collections:
Exact Numeric Data Types in SQL Server Transact-SQL
What are exact numeric data types supported in SQL Server Transact-SQL?
✍: FYIcenter.com
Exact numeric data types are used to hold numeric values truncated to a specific precision and scale.
There are 8 different exact numeric data types supported in SQL Server Transact-SQL:
1. BIGINT - Used to hold big integers with 8-byte storages to store 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).
2. INT (or INTEGER) - Used to hold normal integers with 4-byte storages to store integers in the range of -2^31 (-2,147,483,648) to 2^31-1 (2,147,483,647).
3. SMALLINT - Used to hold small integers with 2-byte storages to store integers in the range of -2^15 (-32,768) to 2^15-1 (32,767).
4. TINYINT - Used to hold tiny integers with 1-byte storages to store integers in the range of 0 to 255.
5. BIT - Used to hold single bit values: 0 and 1.
6. DECIMAL (or DEC, or NUMERIC) - Used to hold values with different precisions and scales specified in the format of DECIMAL(p,s), where p defines the precision and s defines the scale. For example, DECIMAL(9,2) can hold values of 9 digits with 2 digits in the fractional part. The maximum precision supported is 38.
7. MONEY - Used to hold large currency values with 8-byte storages to store values in the range of -922,337,203,685,477.5808 to 922,337,203,685,477.5807. So MONEY is similar to DECIMAL(19,4).
8. SMALLMONEY - Used to hold small currency values with 4-byte storages to store values in the range of - 214,748.3648 to 214,748.3647. So SMALLMONEY is similar to DECIMAL(7,4).
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
⇒ Overflow Errors with INT Values in SQL Server Transact-SQL
⇐ List of Data Types in SQL Server Transact-SQL
2017-04-22, 1770🔥, 0💬
Popular Posts:
How To Connect the Oracle Server as SYSDBA in Oracle? This is Step 4. The best way to connect to the...
How To Change the Password for Your Own User Account in MySQL? If you want to change the password of...
How To Break Query Output into Pages in MySQL? If you have a query that returns hundreds of rows, an...
How To Create a Table Index in Oracle? If you have a table with a lots of rows, and you know that on...
How To Convert Numeric Values to Character Strings in MySQL? You can convert numeric values to chara...