SQL 2005 建立索引问题

来源:百度知道 编辑:UC知道 时间:2024/05/22 13:26:47
if exists(select * from sysindexes where [name] = 'IX_Stumarks_LabExam')
drop index stumarks.IX_Stumarks_LabExam
create nonclustered index IX_Stumarks_LabExam
on stumarks(labexam)
with fillfactor = 30

go

select * from stumarks (index = stumarks.IX_Stumarks_LabExam)
where labexam between 60 and 90
go

建立索引的代码能够正常执行,但是通过查看的时候,老是提示以下内容:

消息 1018,级别 15,状态 1,第 2 行
'index' 附近有语法错误。如果它要作为表提示的一部分,则必须有 WITH 关键字和圆括号。有关正确的语法,请参阅 SQL Server 联机丛书。

为是什么?急,请高手帮忙解决一下,谢谢

根据索引查询的时候有问题:
正确的写法:
select * from Table_Name with(index='IX_Name')
所以应该这样写:
select * from stuMarks with(index='stumarks.IX_StuMarks_LabExam')
where labExam between 60 and 90
go