Link to home
Start Free TrialLog in
Avatar of Eric
EricFlag for United States of America

asked on

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

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?
ASKER CERTIFIED SOLUTION
Avatar of Vitor Montalvão
Vitor Montalvão
Flag of Switzerland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Eric

ASKER

that was it. thanks
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.
Avatar of Eric

ASKER

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)
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.
Avatar of Eric

ASKER

thanks for the heads up