为SQL Server 2012事务性复制在订阅数据库上启用非聚集索引的生成

为SQL Server 2012事务性复制在订阅数据库上启用非聚集索引的生成,sql,sql-server,sql-server-2012,replication,transactional-replication,Sql,Sql Server,Sql Server 2012,Replication,Transactional Replication,我们有一个SQL脚本,用于创建发布及其文章,以及请求订阅。这是非常基本的,因为我们没有明确排除任何文章,而是将它们全部带到订阅服务器(我们的报告使用的用于查询的数据库,以防止应用程序数据库上的过度负载) 作为在源数据库和表中的每个项目上设置发布项目循环的一部分,脚本将执行以下操作: DECLARE @Ins nvarchar(255) = 'CALL sp_MSins_'+@articleSchema+@articleName DECLARE @Del nvarchar(255)

我们有一个SQL脚本,用于创建发布及其文章,以及请求订阅。这是非常基本的,因为我们没有明确排除任何文章,而是将它们全部带到订阅服务器(我们的报告使用的用于查询的数据库,以防止应用程序数据库上的过度负载)

作为在源数据库和表中的每个项目上设置发布项目循环的一部分,脚本将执行以下操作:

    DECLARE @Ins nvarchar(255) = 'CALL sp_MSins_'+@articleSchema+@articleName
    DECLARE @Del nvarchar(255) = 'CALL sp_MSdel_'+@articleSchema+@articleName
    DECLARE @Upd nvarchar(255) = 'CALL sp_MSupd_'+@articleSchema+@articleName

exec sp_addarticle
        @publication = @PublishName, 
        @article = @Joined, 
        @source_owner = @articleSchema,
        @source_object = @articleName,
        @type = N'logbased',
        @description = null, 
        @creation_script = null, 
        @pre_creation_cmd = N'drop', 
        @schema_option = 0x00000000080350DF, 
        @identityrangemanagementoption = N'manual',
        @destination_table = @articleName,
        @destination_owner = @articleSchema, 
        @vertical_partition = N'false', 
        @ins_cmd = @Ins,
        @del_cmd = @Del, 
        @upd_cmd = @Upd
我的问题是
sp\u addarticle
存储过程的
@schema\u选项
参数

我使用了这里的脚本:

为了检查我的0x00000000080350DF的计算(按位或)值,根据该脚本,已为表项目启用了以下选项:

   **SCHEMA OPTIONS HERE ARE**  
—————————————
0x01 Generates the object creation script (CREATE TABLE, CREATE PROCEDURE, and so on). This value is the default for stored procedure articles.
0x02 – Generates the stored procedures that propagate changes for the article, if defined.
0x04 – Identity columns are scripted using the IDENTITY property.
0x08 – Replicate timestamp columns. If not set, timestamp columns are replicated as binary.
0x10 – Generates a corresponding clustered index. Even if this option is not set, indexes related to primary keys and unique constraints are generated if they are already defined on a published table.
0x40 – Generates corresponding nonclustered indexes. Even if this option is not set, indexes related to primary keys and unique constraints are generated if they are already defined on a published table.
0x80 – Replicates primary key constraints. Any indexes related to the constraint are also replicated, even if options 0x10 and 0x40 are not enabled.
0x1000 – Replicates column-level collation
0x4000 – Replicates UNIQUE constraints. Any indexes related to the constraint are also replicated, even if options 0x10 and 0x40 are not enabled
0x10000 – Replicates CHECK constraints as NOT FOR REPLICATION so that the constraints are not enforced during synchronization
0x20000 – Replicates FOREIGN KEY constraints as NOT FOR REPLICATION so that the constraints are not enforced during synchronization
0x8000000 – Creates any schemas not already present on the subscriber
如您所见,似乎应该为表项目启用用于生成非聚集索引的0x40选项

但是启动快照代理后,会生成一个快照,日志读取器代理会执行它的操作,如果我访问发布的属性,我可以看到对于表项目,“复制非聚集索引”的设置设置设置为false

有人知道为什么没有为表项目启用此选项吗?我一直在试图解释technet上的文档:但还没有找到忽略此标志的原因

我不能仅仅更改management studio中“属性”对话框中的选项,因为对于我们的产品,我们不必直接访问客户端的SQL Server实例,而是必须通过powershell从安装计算机远程执行脚本,此脚本就是其中之一


提前感谢。

索引视图的默认架构选项不包括聚集索引。默认情况下,使用GUI设置文章时,只复制索引视图的模式,而不复制索引


要复制索引,可以将sp_addarticle的脚本更改为0x000000000800001,并将@schema_选项从0x000000000800051替换为0x000000000800051

索引视图的默认架构选项不包括聚集索引。默认情况下,使用GUI设置文章时,只复制索引视图的模式,而不复制索引


要复制索引,可以将sp_addarticle的脚本更改为0x000000000800001,并将@schema_选项从0x000000000800051替换为0x000000000800051

对不起,也许我不清楚。我试图为正在复制的表而不是索引视图设置选项。根据引用的脚本,我已经设置了这样做的选项,但它没有发生。可能是与SQL版本有关?对不起,可能我不清楚。我试图为正在复制的表而不是索引视图设置选项。根据引用的脚本,我已经设置了这样做的选项,但它没有发生。可能与SQL版本有关?我看不到您的脚本有任何问题,此线程似乎相关。我看不到您的脚本有任何问题,此线程似乎相关