Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Replication (2005)
 Issue with Join Filters in Merge Replication

Author  Topic 

nabeelfarid
Starting Member

3 Posts

Posted - 2007-10-26 : 12:04:08
hi guys ..hope you all doing well... I am new to Merge Replication and I am having an issue using Merge Replication filters... I am sure somebody here must have come across the issue... I have 3 tables in my Publication Users, Orders, OrderItems... Users have 1-* relationship with Orders and Orders have 1-* relation ship with OrderItems.

In my application, Users create Orders and Order Items. While creating Order Items, an item can be assigned to a different user to review it. So OrderItems table also have AssignedUserID (foreign key with Users table) in it.

Now when the user syncs, I want to filter out all the Orders and OrderItems that belongs to that User.

To do this, In my Publication i have got a root parameterisze filter on Users table based on UserID. The Users table have a join filter with Orders tables which in turns joins with OrderItems. This is fairly simple and works smoothly. The join filters looks like

Users filter: Users.UserID = HostName()
---Orders filter: Users.UserID = Orders.UserID
---OrderItems filter: Orders.ID = OrderItems.OrderID

Now in addition to this, what i also want is to filter out all the OrderItems that have been assigned to the user. For this i put an OR condition in OrderItems to check on AssignedUserID. The filters look like this

Users filter: Users.UserID = HostName()
---Orders filter: Users.UserID = Orders.UserID
---OrderItems filter: Orders.ID = OrderItems.OrderID OR OrderItems.AssignedUserID = HostName()


...but when i sync, the OrderItems with AssignedUserID doesnot get downloaded. I am not sure how to achieve this? Deos anyone have any idea how can i do this?

I have treid different combinations of Joins but no joy. somestimes it gives me foriegn key violation error and sometimes it downloads all the Users, Orders and OrderItems without performing any filtering.
   

- Advertisement -