Merge Replication 无法复制 UD 类型

Merge Replication fails to replicate UD type

我有一个包含一些用户定义类型的数据库。据我了解,Merge Replication 会自动包含所使用的 UD 类型。其中一种类型是 table 变量 在函数中使用。在发布者网站上工作正常,但在订阅者网站上它无法同步。为什么会这样?

错误如下:

The schema script 'some name.sch' could not propagated to the subscriber.

当我跟踪错误时:

Cannot find data type dbo.someName

我觉得本论坛Hilary Cotter的回答应该对你有帮助:

Transactional Replication and User Defined Data Types

我会在这里引用它以防 link 损坏:

You have the option of replicating user defined data types via a pre-snapshot script.

You also have the option of replicating user defined data types as the base data type. This is the convert data types section of the article properties dialog. By default it is false, you would want to set it to true to have them converted to a base datatype. For example if you have a user data type of varchar(11) (ie EXEC sp_addtype ssn, 'VARCHAR(11)', 'NOT NULL') , it would be replicated as varchar(11) and not ssn.

pre-snapshot 脚本的第一个选项可通过发布属性 -> 快照访问。我假设您需要在那里提供一个脚本,该脚本将检查给定的用户定义类型是否在订阅者中尚不存在,然后创建它,否则跳过:

第二个建议的解决方案可通过个别文章属性访问:

看看以上内容是否能帮助您解决问题。当然也有在订阅者处手动创建丢失的UDT的解决方案。