Translate

Sunday, April 21, 2013

INCLUDE Index Column Order

You can create an include index as shown below.

USE [AdventureWorks2012]
GO

CREATE UNIQUE NONCLUSTERED INDEX
[AK_Product_ProductNumber] ON [Production].[Product]
(
[ProductNumber] ASC
)
INCLUDE (
[Class],
[Color]
)
GO

So in this there are two columns are included in INCLUDE clause. So the question is, will the column order matters?


Since it is not only the columns in the SELECT list that need to be present in the INCLUDE clause, order of those columns is irrelevant.


However, if you look the UI of INCLUDE index, you will see following screen.


image


In the above screen, you can see that there is an option of changing the order by pressing Move Up or Move Down buttons.


So the question is, if the order of the columns is irrelevant, why you have an option of changing it?

No comments:

Post a Comment