1

Is it possible to add a geography data type column to an index as an included column?

I am using SQL Server 2008 and the option is greyed out!

It is really annoying as my query has to lookup each row using the clustered index instead of just getting the geography value from a covering index.

I can't find any information about this online.

Has this changed in SQL Server 2012?

2
  • 1
    Have you tried writing the CREATE INDEX statement yourself? msdn.microsoft.com/en-us/library/ms188783(v=sql.100).aspx All data types are allowed except text, ntext, and image. The index must be created or rebuilt offline (ONLINE = OFF) if any one of the specified non-key columns are varchar(max), nvarchar(max), or varbinary(max) data types. Commented Jul 2, 2014 at 8:54
  • Script worked - seems Managment Studio is too dumb Commented Jul 2, 2014 at 8:59

1 Answer 1

1

Seems that Management Studio 2008 is too dumb to recognize that Geography data types can be included in an index as an 'Included Column'

Scripting the index creation works fine for Geography types.

CREATE UNIQUE NONCLUSTERED INDEX [IX_mbrAccount_mbrID] ON [dbo].[mbrAccount] 
(
    [mbrID] ASC
)
INCLUDE ( 
    [mbrNickname],
    [geoPosition]
) 
WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON, FILLFACTOR = 95) ON [PRIMARY]

The execution plan confirms that the column is being used by the index.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.