次の方法で共有


SQL Server でマージ パブリケーション スナップショットが失敗し、スクリプトエラーが発生する

この記事は、マージ パブリケーション スナップショットの作成時に発生する Script の失敗 エラーを回避するのに役立ちます。

元の製品バージョン: SQL Server 2014、SQL Server 2012
元の KB 番号: 3179862

症状

SQL Server 2014 または 2012 では、ジオメトリまたは geography データ型を持つテーブルを含むマージ パブリケーションを作成します。 空間インデックスをコピーするには、アーティクルの [空間インデックスのコピー] オプションを True に設定して、マージによって空間インデックスがレプリケートされるようにします。 ただし、スナップショットを実行すると失敗します。 レプリケーション モニターを起動し、パブリッシャーとパブリケーションにドリルダウンし、スナップショット エージェントを見つけて、スナップショット実行の詳細を表示すると、次のエラー メッセージが表示されます。

Source: Microsoft.SqlServer.Smo
Target Site: System.Collections.Generic.IEnumerable`1[System.String] ScriptWithList(Microsoft.SqlServer.Management.Smo.DependencyCollection, Microsoft.SqlServer.Management.Smo.SqlSmoObject[], Boolean)
>Message: Script failed for Server 'CMSQL'.
Stack: at Microsoft.SqlServer.Management.Smo.Scripter.ScriptWithList(DependencyCollection depList, SqlSmoObject[] objects, Boolean discoveryRequired)
at Microsoft.SqlServer.Management.Smo.Scripter.EnumScriptWithList(SqlSmoObject[] objects)
at Microsoft.SqlServer.Replication.Snapshot.SmoScriptingManager.ScriptIndexList(Scripter scripter, SqlSmoObject[] smoObjectList)
at Microsoft.SqlServer.Replication.Snapshot.MergeSmoScriptingManager.GenerateTableArticleDriScriptWithSingleBatchConstraints(Scripter scripter, BaseArticleWrapper articleWrapper, Table smoTable)
at Microsoft.SqlServer.Replication.Snapshot.MergeSmoScriptingManager.GenerateTableArticleScripts(ArticleScriptingBundle articleScriptingBundle)
at Microsoft.SqlServer.Replication.Snapshot.MergeSmoScriptingManager.GenerateArticleScripts(ArticleScriptingBundle articleScriptingBundle)
at Microsoft.SqlServer.Replication.Snapshot.SmoScriptingManager.GenerateObjectScripts(ArticleScriptingBundle articleScriptingBundle)
at Microsoft.SqlServer.Replication.Snapshot.SmoScriptingManager.DoScripting()
at Microsoft.SqlServer.Replication.Snapshot.SqlServerSnapshotProvider.DoScripting()
at Microsoft.SqlServer.Replication.Snapshot.MergeSnapshotProvider.DoScripting()
at Microsoft.SqlServer.Replication.Snapshot.SqlServerSnapshotProvider.GenerateSnapshot()
at Microsoft.SqlServer.Replication.SnapshotGenerationAgent.InternalRun()
at Microsoft.SqlServer.Replication.AgentCore.Run() (Source: Microsoft.SqlServer.Smo, Error number: 0)
Get help: `http://help/0`
Source: Microsoft.SqlServer.Smo
Target Site: Void CheckTargetVersion(Microsoft.SqlServer.Management.Smo.SqlServerVersionInternal, Microsoft.SqlServer.Management.Smo.SqlServerVersionInternal, System.String)
Message: Error with spatial index [IX_GeographicEntity_Outline]. GEOMETRY_AUTO_GRID and GEOGRAPHY_AUTO_GRID are not supported in SQL Server 2008.
Stack: at Microsoft.SqlServer.Management.Smo.SqlSmoObject.CheckTargetVersion(SqlServerVersionInternal targetVersion, SqlServerVersionInternal upperLimit, String exceptionText)
at Microsoft.SqlServer.Management.Smo.Index.SpatialIndexScripter.ScriptIndexDetails(StringBuilder sb)
at Microsoft.SqlServer.Management.Smo.Index.IndexScripter.GetCreateScript()
at Microsoft.SqlServer.Management.Smo.Index.ScriptDdl(StringCollection queries, ScriptingPreferences sp, Boolean notEmbedded, Boolean createStatement)
at Microsoft.SqlServer.Management.Smo.Index.ScriptCreate(StringCollection queries, ScriptingPreferences sp)
at Microsoft.SqlServer.Management.Smo.SqlSmoObject.ScriptCreateInternal(StringCollection query, ScriptingPreferences sp, Boolean skipPropagateScript)
at Microsoft.SqlServer.Management.Smo.ScriptMaker.ScriptCreateObject(Urn urn, ScriptingPreferences sp, ObjectScriptingType& scriptType)
at Microsoft.SqlServer.Management.Smo.ScriptMaker.ScriptCreate(Urn urn, ScriptingPreferences sp, ObjectScriptingType& scriptType)
at Microsoft.SqlServer.Management.Smo.ScriptMaker.ScriptCreateObjects(IEnumerable`1 urns)
at Microsoft.SqlServer.Management.Smo.ScriptMaker.DiscoverOrderScript(IEnumerable`1 urns)
at Microsoft.SqlServer.Management.Smo.ScriptMaker.ScriptWorker(List`1 urns, ISmoScriptWriter writer)
at Microsoft.SqlServer.Management.Smo.ScriptMaker.Script(DependencyCollection depList, SqlSmoObject[] objects, ISmoScriptWriter writer)
at Microsoft.SqlServer.Management.Smo.Scripter.ScriptWithListWorker(DependencyCollection depList, SqlSmoObject[] objects, Boolean discoveryRequired)
at Microsoft.SqlServer.Management.Smo.Scripter.ScriptWithList(DependencyCollection depList, SqlSmoObject[] objects, Boolean discoveryRequired) (Source: Microsoft.SqlServer.Smo, Error number: 0)
Get help: `http://help/0`

原因

SQL Server では、 GEOMETRY_AUTO_GRID キーワードまたは GEOGRAPHY_AUTO_GRID キーワードで定義された空間インデックスはサポートされていません。

SQL Server 2012 または SQL Server 2014 でパブリケーションを作成する場合、パブリケーションの下位互換性レベルの設定 (@publication_compatibility_level) では、90RTM と 100RTM の設定が許可されます。 そのため、マージ パブリケーションを作成すると、SQL Server 2008 との互換性が強制されます。 ただし、SQL Server 2008 との下位互換性のため、空間インデックスをコピーすることはできません。

対処法

マージ パブリケーションでこの種類のデータを引き続き使用するには、次のいずれかの回避策を使用します。

  • GEOMETRY_GRIDGEOGRPAHY_GRIDではなく、GEOMETRY_AUTO_GRIDキーワードまたはGEOGRAPHY_AUTO_GRIDキーワードを使用して空間インデックスを定義します。
  • パブリケーションを定義するときは、空間インデックスで定義されているアーティクルを構成し、 Copy 空間インデックス オプションを False に設定します。 次に、サブスクリプションが作成され、サブスクリプションが初期化されたら、サブスクライバー テーブルに空間インデックスを手動で作成します。

対象

  • SQL Server 2012 開発者向け
  • SQL Server 2012 Enterprise
  • SQL Server 2012 Enterprise Core
  • SQL Server 2012 Standard
  • SQL Server 2014 Developer(開発者向け)
  • SQL Server 2014 Enterprise
  • SQL Server 2014 Enterprise Core
  • SQL Server 2014 Standard