'INDEX'附近的语法不正确

时间:2017-01-19 11:40:25

标签: sql-server

创建了索引

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

尝试过查询

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

错误

  

'INDEX'附近的语法不正确。如果这是作为a的一部分   表提示,       现在需要WITH关键字和括号。

1 个答案:

答案 0 :(得分:3)

使用WITH子句

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