Does Column Order Matter in SQL Server

The short answer is it doesn’t. I guess that’s the long answer as well.

A few people have posted questions about whether the PK needs to be the first column, and does it matter if you have CHAR or VARCHAR together, should integers be first, etc.

It doesn’t matter. Fixed width data is stored first, variable length is offset from the end of the page, and LOB data is either in row with variable data, or on another page.

However since the server reads a page at a time, and has to rip through the row to get the next row anyway, it doesn’t matter where you put the data in design.

I tend to put the PK first, but I have done things like put a datestamp first, just to make it easier to read when I query the data.

About way0utwest

Editor, SQLServerCentral
This entry was posted in Blog, Uncategorized and tagged . Bookmark the permalink.