我正在尝试执行以下命令以强制更新使用非聚集索引:
UPDATE Flights SET Airtime=5555678 WHERE Distance=10000 OPTION (TABLE HINT(Flights,INDEX (DistanceIndex)))
……这是错误的:
Msg 8724,Level 16,State 1,Line 75
Cannot execute query. Table-valued or OPENROWSET function ‘Flights’ cannot be specified in the TABLE HINT clause.
关于如何在TABLE HINT语句中正确形成语法,我找不到任何明确的建议.
请问任何人都可以告诉我哪里出错了?
解决方法
试试以下:
UPDATE F SET F.Airtime=5555678 FROM Flights F WITH (INDEX (DistanceIndex)) WHERE F.Distance=10000
要么
UPDATE Flights SET Airtime=5555678 FROM Flights -- this line is added to your initial query WHERE Distance=10000 OPTION (TABLE HINT(Flights,INDEX (DistanceIndex)))