代码报错:
'OPTIMIZE_FOR_SEQUENTIAL_KEY' is not a recognized CREATE TABLE option.
报错部分代码:
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON,OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF)
报错原因:
您的目标 SQL Server 只是一个旧版本。 OPTIMIZE_FOR_SEQUENTIAL_KEY 是 SQL Server 2019 中的一项新功能。
解决方案:
可以简单地删除该选项。如果您没有将任何选项设置为非默认值,您可以删除所有这些选项。或者查看您的主机是否有可用的 SQL Server 2019。
即:直接将 OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF 删除。
原版解答:
Your target SQL Server is simply an older version. It's SQL Server 2014 SP3 CU4 to be exact, and OPTIMIZE_FOR_SEQUENTIAL_KEY is a new feature in SQL Server 2019. SSMS scripting always recites all the options, even when set to the default value to ensure full fidelity scripting, which sometimes a pain.
You can simply remove that option and the script should be compatible with SQL 2014. In fact you can remove all those options if you haven't set any to a non-default value.
Or see if your hoster has SQL Server 2019 available. Or upgrade your hoster.