From e0de5ce366897400f9d434cedfba178d32be00e9 Mon Sep 17 00:00:00 2001 From: Sergii Syrovatchenko Date: Sat, 20 Nov 2021 09:10:07 +0200 Subject: [PATCH] Fix 'ONLINE' is not a recognized ALTER INDEX REBUILD PARTITION option --- Server/Index.cs | 4 +++- Server/ServerInfo.cs | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Server/Index.cs b/Server/Index.cs index bd75893..23470aa 100644 --- a/Server/Index.cs +++ b/Server/Index.cs @@ -158,7 +158,9 @@ public string GetQuery() { (!IsAllowCompression ? "" : $"DATA_COMPRESSION = {compression}, ") + - $"ONLINE = {onlineRebuild}, " + + (Settings.ServerInfo.MajorVersion <= ServerVersion.Sql2012 && IsPartitioned // 'ONLINE' is not a recognized ALTER INDEX REBUILD PARTITION option + ? "" + : $"ONLINE = {onlineRebuild}, ") + $"MAXDOP = {Settings.Options.MaxDop});"; break; diff --git a/Server/ServerInfo.cs b/Server/ServerInfo.cs index b038819..11e17bc 100644 --- a/Server/ServerInfo.cs +++ b/Server/ServerInfo.cs @@ -36,7 +36,7 @@ public override string ToString() => $"SQL Server {ProductVersion} " + // https://sqlperformance.com/2014/06/sql-indexes/hotfix-sql-2012-rebuilds public bool IsOnlineRebuildAvailable => IsAzure - || (MajorVersion >= ServerVersion.Sql2014 && IsMaxEdititon); + || (MajorVersion >= ServerVersion.Sql2008 && IsMaxEdititon); private string ProductVersion { get {