当我使用文章过滤器和删除操作时,我的事务复制有问题。当我将新数据插入发布者时,所有符合指定过滤器的数据都会插入到订阅者中 - 一切正常。当我从发布者删除某些数据时,并不是所有符合指定过滤条件的数据都会从订阅者中删除,而我也不知道原因。
我有三台服务器: A - 发布者(Microsoft SQL Server 2012), B - 分销商(Microsoft SQL Server 2012), C - 订户(Microsoft SQL Server 2012)。
我的发布商数据库中有六个表。每个表都有主键,其中一些表有外键,如附图所示:
我想将第一个制造商(制造商ID = 1)数据从发布商复制到订阅者,因此我使用这些过滤器:
SELECT <published_columns> FROM [dbo].[Manufacturer]
WHERE [dbo].[Manufacturer].ID IN (Select M.ID from [dbo].[Manufacturer] AS M where M.ID = 1)
SELECT <published_columns> FROM [dbo].[Catalog]
WHERE [dbo].[Catalog].ID IN (Select C.ID from [dbo].[Catalog] AS C
INNER JOIN [dbo].[Manufacturer] AS M ON M.ID = C.MID where M.ID = 1)
SELECT <published_columns> FROM [dbo].[Cars]
WHERE ID IN (Select CA.ID from [dbo].[Cars] AS CA
INNER JOIN [dbo].[Catalog] AS C ON C.ID = CA.CID
INNER JOIN [dbo].[Manufacturer] AS M ON M.ID = C.MID where M.ID = 1)
SELECT <published_columns> FROM [dbo].[CarParts]
WHERE ID IN (Select CP.ID from [dbo].[CarParts] AS CP
INNER JOIN [dbo].[Cars] AS CA ON CA.ID = CP.CarID
INNER JOIN [dbo].[Catalog] AS C ON C.ID = CA.CID
INNER JOIN [dbo].[Manufacturer] AS M ON M.ID = C.MID where M.ID = 1)
SELECT <published_columns> FROM [dbo].[Parts]
WHERE ID IN (Select P.ID from [dbo].[Parts] AS P
INNER JOIN [dbo].[CarParts] AS CP ON CP.PID = P.ID
INNER JOIN [dbo].[Cars] AS CA ON CA.ID = CP.CarID
INNER JOIN [dbo].[Catalog] AS C ON C.ID = CA.CID
INNER JOIN [dbo].[Manufacturer] AS M ON M.ID = C.MID where M.ID = 1)
SELECT <published_columns> FROM [dbo].[PartDetails]
WHERE ID IN (Select PD.ID from [dbo].[PartDetails] AS PD
INNER JOIN [dbo].[Parts] AS P ON P.ID = PD.PartID
INNER JOIN [dbo].[CarParts] AS CP ON CP.PID = P.ID
INNER JOIN [dbo].[Cars] AS CA ON CA.ID = CP.CarID
INNER JOIN [dbo].[Catalog] AS C ON C.ID = CA.CID
INNER JOIN [dbo].[Manufacturer] AS M ON M.ID = C.MID where M.ID = 1)
当我将新数据插入发布商CarParts表,Parts表或PartDetails表时,所有符合指定过滤器(制造商ID = 1)的数据都会插入订阅者。
当我从发布商CarParts表中删除数据时,部件表或PartDetails表并非从订户中删除满足指定过滤器(制造商ID = 1)的所有数据 - 仅从CarParts表中删除数据,但不从Parts表中删除数据和PartDetails表。
相同的过滤器用于插入和删除操作。哪里可能是问题?也许是Microsoft SQL Server 2012 Bug?
答案 0 :(得分:0)
问题在于删除操作序列。
问题解决了。