Partager via


Échec de l’instantané de publication de fusion avec l’erreur d’échec du script dans SQL Server

Cet article vous aide à contourner l’erreur d’échec du script qui se produit lors de la création d’un instantané de publication de fusion.

Version du produit d’origine : SQL Server 2014, SQL Server 2012
Numéro de base de connaissances d’origine : 3179862

Symptômes

Dans SQL Server 2014 ou 2012, vous créez une publication de fusion qui contient une table qui a un type de données geometry ou geography. Pour copier votre index spatial, vous avez défini l’option Copier les index spatiaux de l’article sur True afin que la fusion réplique les index spatiaux. Toutefois, lorsque l’instantané s’exécute, il échoue. Si vous démarrez le Moniteur de réplication et explorez l’éditeur et la publication, recherchez l’agent d’instantané et affichez les détails de l’exécution de l’instantané, le message d’erreur suivant s’affiche :

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`

La cause

SQL Server ne prend pas en charge les index spatiaux définis avec les mots clés ou GEOMETRY_AUTO_GRID les GEOGRAPHY_AUTO_GRID mots clés.

Lorsque vous créez une publication dans SQL Server 2012 ou SQL Server 2014, le paramètre de niveau de compatibilité descendante (@publication_compatibility_level) de la publication autorise les paramètres de 90RTM et 100RTM. Par conséquent, la compatibilité avec SQL Server 2008 est forcée lorsque vous créez une publication de fusion. Toutefois, en raison de la compatibilité descendante avec SQL Server 2008, les index spatiaux ne peuvent pas être copiés.

Contournement

Pour continuer à utiliser ce type de données dans une publication de fusion, utilisez l’une des solutions de contournement suivantes :

  • Définissez l’index spatial à l’aide du GEOMETRY_GRID ou GEOGRPAHY_GRID des mots clés au lieu de GEOMETRY_AUTO_GRID ou GEOGRAPHY_AUTO_GRID.
  • Lorsque vous définissez la publication, configurez l’article défini avec un index spatial, en définissant l’option Copier les index spatiaux sur False. Ensuite, une fois les abonnements créés et l’abonnement initialisé, créez manuellement l’index spatial sur la table de l’abonné.

S’applique à

  • SQL Server 2012 Developer
  • 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