Aug 11, 2013

Incorrect syntax near ''. If this is intended as a part of a table hint, A WITH keyword and parenthesis are now required. See SQL Server Books Online for proper syntax.


Suppose we have created a table tblPrice in sql server:

CREATE TABLE tblPrice(
     ItemID INT,
     Location VARCHAR(50),
     Price MONEY
)

Now we are creating a non-clustered index on table tblPrice

CREATE INDEX IX_Price ON tblPrice(Location)

Now if we will execute following sql query:

SELECT * FROM tblPrice (INDEX = IX_Price)

We will get error message like:

Incorrect syntax near ''. If this is intended as a part of a table hint, A WITH keyword and parenthesis are now required. See SQL Server Books Online for proper syntax.

Cause: It necessary to use WITH clause when we want use table hints INDEX.

Solution:

SELECT * FROM tblPrice WITH(INDEX = IX_Price)

No comments:

Post a Comment