Make it Short and Sweet

When you choose a primary key, remember that SQL Server manages simple data types more easily than variable-length character fields.

Michelle A. Poolet

January 23, 2002

1 Min Read
ITPro Today logo in a gray background | ITPro Today

Readers often ask me which data type is the best to use for a primary key. I always recommend the simplest of data types—either an integer or a short-character data type. Managing these data types is easier than managing more complex data types such as variable-length character data types, which require additional processing with each operation.

Every time SQL Server has to access a record that contains variable-length fields, for each data record and for each index built on those data records, SQL Server has to check the column offset array to determine at which point the variable-length field begins in the data record. SQL Server's additional activity creates increased overhead that might become a liability when your databases grow or when the queries accessing the data become more complicated.

Main article: Surrogate Key vs. Natural Key

Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like