Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
过去,我使用Alter Database语句更改了 SQL Server 兼容性级别。有没有办法为单个查询而不是为整个数据库设置它?
Alter Database
从更高版本的 SQL 开始(我相信 SQL 2017 及之后的版本),您可以将其添加为查询提示。
SELECT * FROM my_table QUERY_OPTIMIZER_COMPATIBILITY_LEVEL_100
例如,在 2008 模式下运行。或者您可以将 100 更改为 150 以在 2019 兼容模式或介于两者之间的任何位置运行。