Monday, February 20, 2012

Parameterized filters on publication?

Does anyone know if you can use any other parameters in the row filters for merge replication besides the functions SUSER_NAME() and HOST_NAME()?

I would like to create a publication for a couple thousand mobile databases to replicate with one SQL Database but filter what data they get based on some parameters. Do I have to hard code WHERE statements into static filters and create a publication for every user (seems a little ridiculous)?

Is there a proper way to do this using the SUSER_NAME and give each user a different connection name that will filter data properly?

Thanks,

Patrick Kafka

sorry, i'm not following you. Can you give an example of what exactly you want to filter on and what parameters you're referring to, or how you envision your filter to look like?|||

You can achieve what you wish using the SUSER_SNAME filter.

Lets say you have a table: customers (id int, Name varchar(20)

and it has the following values:

(1, ;'Steve')

(2, 'Bill')

(3, 'Peter')

(4, 'Jay')

Lets say your filter is: subset_filterclause='Name=SUSER_SNAME()'

With this filter, when a mobile user comes in (say Bill), he will send value Bill to SUSER_SNAME and hence get row with id=2.

Similarly for Peter, the row with id=3 will be sent.

Is that what you want to achieve?

No comments:

Post a Comment