1.3. SQL Server Data Types

Now that you're familiar with the base objects of a SQL Server database, let's take a look at the options that SQL Server has for one of the fundamental items of any environment thathandles data: data types. 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 2005 has the intrinsic data types shown in the following table:

Data Type NameClassSize in BytesNature of the Data
BitInteger1The size is somewhat misleading. The first bit data type in a table takes up one byte; the next seven make use of the same byte. Allowing nulls causes an additional byte to be used.
BigintInteger8This 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 −263 to 263−1. That's plus or minus about 92 quintrillion.
IntInteger4Whole numbers from −2,147,483,648 to 2,147,483,647.
SmallIntInteger2Whole numbers from −32,768 to 32,767.
TinyIntInteger1Whole numbers from 0 to 255.
Decimal or NumericDecimal/NumericVariesFixed precision and scale from −1038−1 to 1038−1. The two names are synonymous.
MoneyMoney8Monetary units from −263 to 263 plus precision to four decimal places. Note that this could be any monetary unit, not just dollars.
SmallMoneyMoney4Monetary units from −214,748.3648 ...

Get Professional SQL Server™ 2005 Programming now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.