Datasheet

Chapter 1: Being Objective: Re-Examining Objects in SQL Server
columns that they map, they are separate objects and are as such, not necessarily updated (the default is
for automatic updating, but you can change it to manual update) when changes happen in the database.
SQL Ser ver Data Types
This is an area of relatively significant change over the last release or two. SQL Server 2005 began the
change in blob related data types (
text
and
ntext
became
varchar(max)
and
nvarchar(max)
,andimage
became
varbinary(max)
). Now SQL Server 2008 adds several new time and date related data types as
well as a special data type for handling hierarchical data.
Note that since this book is intended for developers and that no developer could survive for 60 seconds
without an understanding of data types, I’m going to assume that you already know how data types work
and just need to know the particulars of SQL Server data types.
SQL Server 2008 has the intrinsic data types shown in the following table:
Data Type Name Class Size in Bytes Nature of the Data
Bit
Integer 1 The size is somewhat misleading. The
first
bit
data type in a table takes up 1
byte; the next seven make use of the same
byte. Allowing nulls causes an additional
byte to be used.
Bigint
Integer 8 This just deals with the fact that we use
larger and larger numbers on a more
frequent basis. This one allows you to use
whole numbers from 2
63
to 2
63
1. That’s
plus or minus about 92 quintrillion.
Int
Integer 4 Whole numbers from 2,147,483,648 to
2,147,483,647.
SmallInt
Integer 2 Whole numbers from 32,768 to 32,767.
TinyInt
Integer 1 Whole numbers from 0 to 255.
Decimal
or
Numeric
Decimal/
Numeric
Varies Fixed precision and scale from 10
38
–1 to
10
38
1. The two names are synonymous.
Money
Money 8 Monetary units from 2
63
to 2
63
plus
precision to four decimal places. Note
that this could be any monetary unit, not
just dollars.
SmallMoney
Money 4 Monetary units from 214,748.3648 to
+214,748.3647.
Float
(also a
synonym for
ANSI
Real
)
Approximate
Numerics
Varies Accepts an argument (for example,
Float(20)
) that determines size and
precision. Note that the argument is in
bits, not bytes. Ranges from 1.79E + 308
to 1.79E + 308.
12