Please start any new threads on our new site at We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 SQL Server Administration (2008)
 Column Order for Primary Key
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Starting Member

17 Posts

Posted - 08/20/2013 :  21:39:18  Show Profile  Reply with Quote
I understand that the order of columns doesnt change performance but if my primary key is made of two or more columns and its not the first columns, but spreadout in the table, would that affect index seeks or scans or affect performance. Example below.

Lets say my primarykey is OfficeName, OfficeCounty, OfficeState
and my table script is


As you can see my primary key is spread out in the table, does it matter?

Very Important crosS Applying yaK Herder

52326 Posts

Posted - 08/21/2013 :  00:33:27  Show Profile  Reply with Quote
the order of columns in the index do matter


SQL Server MVP
Go to Top of Page

Bustaz Kool
Flowing Fount of Yak Knowledge

1834 Posts

Posted - 08/22/2013 :  11:22:31  Show Profile  Reply with Quote
The order of the columns within the index does matter, as has been pointed out already. The order of those columns within the table does not (I'm not sure if that was your question or not). Moving OfficeCounty and/or OfficeState to be "earlier" in the table would have no effect on your index performance.

The cure for anything is salt water -- sweat, tears, or the sea. -Isak Dinesen
Go to Top of Page

Starting Member

17 Posts

Posted - 08/23/2013 :  13:37:45  Show Profile  Reply with Quote

You got my question right and Thanks for answering it. Thats what I thought, but wanted to make sure. I do know that the order of index matters. Thanks.

I designed in Erwin, but I guess there is a check box which you should uncheck (and its set by default) which makes it create the table in random colum order. If you uncheck it, it would create in the exact column order you designed in Erwin.

Why on earth that it would be set to scramble by default is beyond me.
Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.03 seconds. Powered By: Snitz Forums 2000