Database Reference
In-Depth Information
database developer after the database has been built. With that said, let's
look at the data types available in SQL Server 2008.
Numeric Data Types
Our databases need to store many kinds of numbers that we use day to day.
Each of these numbers is unique and requires us to store varying pieces of
data. These differences in numbers and requirements dictate that SQL
Server be able to support 11 numeric data types. Following is a review of
all the numeric data types available in SQL Server. Also, Table 3.1 shows
the specifications on each numeric data type.
Table 3.1
Numeric Data Type Specifications
Data Type
Value Range
Storage
bigint
-9,223,372,036,854,775,808 through 9,223,372,036,854,775,807
8 bytes
bit
0 or 1
1 byte (minimum)
decimal
Depends on precision and scale
5-17 bytes
float
-1.79E+308 through -2.23E-308, 0,
4 or 8 bytes
and 2.23E-308 through 1.79E+308
int
-2,147,483,648 to 2,147,483,647
4 bytes
money
-922,337,203,685,477.5808 to 922,337,203,685,477.5807
8 bytes
numeric
Depends on precision and scale
5-17 bytes
real
-3.40E+38 to -1.18E-38, 0, and 1.18E-38 to 3.40E+38
4 bytes
smallint
-32,768 to 32,767
2 bytes
smallmoney
-214,748.3648 to 214,748.3647
4 bytes
tinyint
0 to 255
1 byte
Int
The int data type is used to store whole integer numbers. Int does not store
any detail to the right of the decimal point, and any number with decimal
data is rounded off to a whole number. Numbers stored in this type must
be in the range of -2,147,483,648 through 2,147,483,647, and each piece
of int data requires 4 bytes to store on disk.
Bigint
Bigint is just what it sounds like: a big integer number. When you need
larger numbers than supported by the int data type, you can use bigint.
Using bigint expands your range from the paltry 2 billion of an int and al-
Search WWH ::




Custom Search