Solved

SQL 2012 create index "incorrect syntax near 'INCLUDE'"

Posted on 2016-10-24
6
73 Views
Last Modified: 2016-10-24
A consultant created me a script to add some indexes, in it, it has a line like so

--sp_helpindex 'tmfWork_HAI'
CREATE NONCLUSTERED INDEX [IX_CreateDate_WI]
      ON [dbo].[tmfWork_HAI]
(
      CreateDate
INCLUDE
(
      WorkOrderKey
);
GO

It generates this error:  
Msg 102, Level 15, State 1, Line 9
Incorrect syntax near 'INCLUDE'.

any idea why?
0
Comment
Question by:Eric
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 49

Accepted Solution

by:
Vitor Montalvão earned 500 total points
ID: 41857083
It's missing a close parenthesis after CreateDate:
CREATE NONCLUSTERED INDEX [IX_CreateDate_WI]
       ON [dbo].[tmfWork_HAI] (CreateDate)
 INCLUDE  (WorkOrderKey);

Open in new window

0
 
LVL 11

Author Closing Comment

by:Eric
ID: 41857274
that was it. thanks
0
 
LVL 69

Expert Comment

by:Scott Pletcher
ID: 41857275
Fyi, your consultant left out the critical WITH clause to explicitly specify at least FILLFACTOR, and to specify the filegroup to create the index on.
1
Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

 
LVL 11

Author Comment

by:Eric
ID: 41857288
hmm.  I have no idea the signfiicance of that. I am a infrastructure guy not SQL guy.

The script has like 30 index creations. Most are more simple than the one above and just look like:

--sp_helpindex 'tsrSR'
CREATE NONCLUSTERED INDEX [IX_ShipToAddrKey]
      ON [dbo].[tsrSR]
(
      ShipToAddrKey
);
GO

Did did a 24 hour analysis of our db performance and came back with a list of suggestions.  One of the suggestions was this list of 30 indexes.  (he also recommended removing a handful)
0
 
LVL 69

Expert Comment

by:Scott Pletcher
ID: 41857413
He might be right on the indexes overall, but he's not really thorough and/or knowledgeable if he didn't also specify an explicit FILLFACTOR.  As a DBA, I would never accept a default FILLFACTOR.
1
 
LVL 11

Author Comment

by:Eric
ID: 41857508
thanks for the heads up
0

Featured Post

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Azure Functions is a solution for easily running small pieces of code, or "functions," in the cloud. This article shows how to create one of these functions to write directly to Azure Table Storage.
A company’s centralized system that manages user data, security, and distributed resources is often a focus of criminal attention. Active Directory (AD) is no exception. In truth, it’s even more likely to be targeted due to the number of companies …
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question