User
User

Reputation: 1363

Incorrect syntax near 'INDEX'

created Index

  CREATE INDEX MasterIndex
 ON [Attendance].[dbo].[Attendence] (location,createdby,program,batch,term)

tried query

SELECT *
 FROM [Attendance].[dbo].[Attendence] USE INDEX (MasterIndex) WHERE createdby='pravin' and term='Term III' and batch='80' and program='computer' and location='AMD'

error

Incorrect syntax near 'INDEX'. If this is intended as a part of a table hint, A WITH keyword and parenthesis are now required.

Upvotes: 0

Views: 3161

Answers (1)

John Cappelletti
John Cappelletti

Reputation: 81950

Use the WITH Clause

SELECT *
 FROM [Attendance].[dbo].[Attendence] WITH (INDEX (MasterIndex)) WHERE ... 

Upvotes: 4

Related Questions