【发布时间】:2017-01-31 13:56:07
【问题描述】:
我们有一个用于创建出版物及其文章的 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_addarticle 存储过程的@schema_option 参数。
为了检查我计算的(按位或)值 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 上的文档:https://technet.microsoft.com/en-us/library/ms173857(v=sql.105).aspx,但没有发现忽略此标志的原因。
我不能只更改管理工作室属性对话框中的选项,因为对于我们的产品,我们不一定可以直接访问客户端的 SQL Server 实例,而是必须通过 powershell 从安装机器远程执行脚本,这个脚本就是其中之一。
提前致谢。
【问题讨论】:
-
我没有看到你的脚本有任何问题,这个线程似乎相关
标签: sql sql-server sql-server-2012 replication transactional-replication