Datasheet

9
Chapter 1: Introducing T-SQL and Data Management Systems
Data Type Storage Description
Integers Note: Signed integers can be both positive and negative,
whereas unsigned integers have no inherent signed value
bigint 8 bytes An 8 - byte signed integer. Valid values are
− 9223372036854775808 through +9223372036854775807.
int 4 bytes A 4 - byte signed integer. Valid values are − 2,147,483,648
through +2,147,483,647.
smallint 2 bytes A double - byte signed integer. Valid values are − 32,768
through +32,767.
tinyint 1 byte A single - byte unsigned integer. Valid values are from
0 through 255.
bit 1 bit Integer data with either a 1 or 0 value.
Exact Numerics
decimal 5 – 17 bytes A predefined, fixed, signed decimal number ranging from
− 100000000000000000000000000000000000001 (− 10
38
+1) to
99999999999999999999999999999999999999 ( + 10
38
− 1).
A
decimal is declared with a precision and scale value that
determines how many decimal places to the left and right
are supported. This is expressed as
decimal[(precision,
[scale])]
. The precision setting determines how
many total digits to the left and right of the decimal point
are supported. The
scale setting determines how many
digits to the right of the decimal point are supported. For
example, to support the number 3.141592653589793,
the
decimal data type would have to be specified as
decimal(16,15) . If the data type were specified
as
decimal(3,2) , only 3.14 would be stored. The scale
defaults to zero and must be between 0 and the precision.
The precision defaults to 18 and can be a maximum of 38.
numeric 5 – 17 bytes The numeric data type is identical to the decimal data
type, so use
decimal instead, for consistency. The
numeric data type is much less descriptive because
most people think of integers as being numeric.
money 8 bytes The money data type can be used to store values from
922,337,203,685,477.5808 to +922,337,203,685,477.5807 of
a monetary unit, such as a dollar, euro, pound, and so on.
The advantage of the
money data type over a decimal
data type is that developers can take advantage of
automatic currency formatting for specific locales. Notice
that the
money data type supports figures to the fourth
decimal place. Accountants like that. A few million of
those ten thousandths of a penny add up after a while!
(continued)
CH001.indd 9CH001.indd 9 3/26/10 11:35:36 AM3/26/10 11:35:36 AM