Schema - Do you always use Varchar?

Last updated by Matthew Parker [SSW] 8 months ago.See history

Use VARCHAR instead of CHAR, unless your data is almost always of a fixed length, or is very short. For example, a Social Security/Tax File number which is always 9 characters. These situations are rare.

SQL Server fits a whole row on a single page, and will never try to save space by splitting a row across two pages.

Running DBCC SHOWCONTIG against tables shows that a table with fixed length columns takes up less pages of storage space to store rows of data.

General rule is that the shorter the row length, the more rows you will fit on a page, and the smaller a table will be.

It allows you to save disk space and it means that any retrieval operation such as SELECT COUNT(*) FROM, runs much quicker against the smaller table.

We open source. Powered by GitHub