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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.