Is it possible to have Client Based Condition in Replication?
Hi I configured the Merge Replication perfectly and its working fine. But now i had a different requirement. I configured my Publication in server of whole database. Now i have different clients (subscribers) in different states. so can i replicate data using stateid from my publisher based on the condition?
You can do this with Parameterized row filters in your publication, this help you to avoid creating multiple publication for each State. The steps are as follows, To improve the replication performance add Column StateID in all the tables that you wish to replicate. If you already have a mapping table between ClientID, Username(Login Name), StateID ignore this step, else create a mapping table with above fields. Once you done this, create publication with paramerized row filters based on the SUSER_SNAME() eg; Client Table (ClientID, ClientName, StateID) and UserTable (UserID, UserName, StateID) and your parameterized filter should be as follows SELECT FROM [dbo].[Clients] WHERE StateID IN (SELECT StateID FROM UserDetails Where UserName = SUSER_SNAME()) Create the subscribers with merge agent account to connect with publisher as the 'UserName' as clients User name mentioned in the UserDetails (Assuming the UserName is either Windows or SQL logins) . Please refer [Parameterized Row Filters] :