I'm trying to create a filtered non-clustered index. In the gui I right-click the Indexes
folder of the table where I want the index. Add the column where the index should be applied, then click on the filter page to add this statement: WHERE eMail IS NOT NULL
. Click OK and I'm presented with this error:
Create failed for Index 'fix_Email'. (Microsoft.SqlServer.Smo)
Incorrect syntax near the keyword 'WHERE'.
Incorrect syntax near the keyword 'with'. If this statement is a common table expression, an xmlnamespaces clause or a change tracking context clause, the previous statement must be terminated with a semicolon. (Microsoft SQL Server, Error: 156)
This comes straight out of a book on SQL Server 2008 Administration. I installed SQL 2012 express to see what differences there would be between the two. All previous examples worked, creating clustered indexes, non-clustered, and covering index. Is this a problem with the book or SQL Server 2012 or maybe the Express edition? I tried placing a semi-colon as suggested by the error message at the end of my WHERE
statment, but that didn't do anything.
I was able to create the index using this code in a query window:
CREATE NONCLUSTERED INDEX fix_Prices
ON dbo.Customers (eMail)
WHERE eMail IS NOT NULL;
why does this work but not using the Management Studio gui?