question

Bhuvans avatar image
Bhuvans asked

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?
sqlsql-server-2008-r2replicationserver
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Cyborg avatar image
Cyborg answered
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][1] [1]: http://msdn.microsoft.com/en-us/library/ms152478.aspx
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Cyborg avatar image
Cyborg answered
It is possible to do so, please check [Filtering Published Data][1] [1]: http://msdn.microsoft.com/en-us/library/ms151775.aspx
1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Bhuvans avatar image Bhuvans commented ·
hi cyborg, But if i do that process for every client i need to create one publication in each server , for example in server i had a table customers (CID,CNAME,CCITY) . I created my publication in server and my subscribers requirement should be in the below way Client 1:- CID,CNAME Client 2:- CNAME,CCITY 2 clients with one publication but with filter data
0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.