Database Design Considerations: Data Types

Microsoft® SQL Server™ version 6.5 and earlier automatically implemented fixed-length columns that allow null values as variable-length columns of the same data type. For example, a char column that allowed null values was treated as a varchar column. This resulted in less space being used when the length of the value stored in the column was less than the maximum column length. SQL Server version 7.0 treats any fixed-length column that allows null values as fixed-length. Therefore, a char column that allows null values is treated as a fixed-length char column.

As a result, the same data now takes more disk space to store and can require more I/O and other processing operations in SQL Server 7.0 compared to earlier versions of SQL Server. To resolve this issue and achieve the same results as SQL Server 6.5 and earlier, use variable-length columns rather than fixed-length columns. For example, use a varchar data type instead of a char data type. However, if all the values in a column are the same length or the lengths of the values do not vary by much, it is more efficient to use a fixed-length column.

Text Data Types

Character strings up to 8,000 bytes in length that needed to be stored using the image data type in SQL Server 6.5 and earlier can now be stored in columns defined with the char and varchar data types. Using a char or varchar data type allows the system-defined character string functions, such as SUBSTRING, to be used on character strings up to 8,000 bytes in length.

See Also

Specifying a Column Data Type

  


(c) 1988-98 Microsoft Corporation. All Rights Reserved.