Should Varchar Columns be last in a table?

  • What is the best practice for the order of columns with a datatype of varchar in a table? Should they be placed last in a table in ascending order or it doesn't matter?

  • Makes no difference. The order you specify the columns just determines the columnIDs, no guarantees that the columns will actually be stored in that order in the data pages.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • The position of variable length made a difference about 15 years ago with version 6.0 but not with any of the current version.

    SQL = Scarcely Qualifies as a Language

  • I agree with the other replies.

    Just for info, when a row is physically stored (in 2005) in the page the following sequence is used:-

    * First, the Header,

    * Followed by Fixed Columns,

    * Then Null Columns,

    * Then Variable Column Pointers,

    * Then Variable Column Data.

    This sequence is always followed irrespective of the order in which the columns are defined (as the previous replys have said).

  • Thanks everyone for their replies!

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply