Datatypes

Datatypes define the type of data that can be stored in tables. When each column is defined, it is assigned a datatype, which enforces basic integrity by limiting the type and size of the data that can be entered. Choosing the correct datatype for each column is crucial to efficient data storage, performance, and application compliance.

SQL Server provides several base datatypes, which are grouped by the type of data that they store. Table 12.2 shows the system-supplied datatypes and their storage capacities.

Table 12.2. System-Supplied Datatypes
Data Type Category SQL Server Data Type Number of Bytes
Character
char[(n)]
varchar[(n)]
text
0–8000 0–2GB
Unicode Character
nchar[(n)]
nvarchar[(n)]
ntext
0–8000

(4000 characters)

0–2GB ...

Get Microsoft® SQL Server™ 2000 Unleashed, Second Edition now with O’Reilly online learning.

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