gpt4 book ai didi

sql-server - SQL Server - 如何在更新命令上提示索引?

转载 作者:行者123 更新时间:2023-12-02 10:09:38 27 4
gpt4 key购买 nike

我正在尝试执行以下命令来强制更新使用非聚集索引:

 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)))

关于sql-server - SQL Server - 如何在更新命令上提示索引?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24975353/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com