all groups > sql server replication > june 2005 >
You're in the

sql server replication

group:

Merge Replication - filtering on arbitrary columns


Merge Replication - filtering on arbitrary columns Diego Mijelshon
6/30/2005 6:18:39 PM
sql server replication:
I'm building a distributed sales system with a central database and about 50
not-always-connected sites.
The schema is something like this:

Customer
Id uniqueidentifier (PK)
Name varchar
Invoice
Site int
Id uniqueidentifier (PK)
CustomerId uniqueidentifier
Total money
Parameters (singleton table)
Site int

When I create an Invoice, it gets the Site from the Parameters table

I'd like to create a merge replication that:
- Maintains the Customers in sync for all sites
- Copies the Invoices from the sites to the central database and sends
changes back to the sites, but does NOT copy the Invoices to others sites

I guess I have to use some kind of filtering (Invoice.Site = (SELECT Site
FROM Parameters)), but I'm having trouble finding out if (and how) this can
be done.

Any ideas?

Thanks a lot!
Diego

Re: Merge Replication - filtering on arbitrary columns Paul Ibison
7/1/2005 12:00:00 AM
Diego,
An example dynamic filter is Country = HOST_NAME() where the function
HOST_NAME() resolves to the NETBIOS name of the (pull) subscriber's
computer. In order to avoid having to rename each subscriber's computer to
have NETBIOS country names and so make all this work, a common solution is
to use the -HOSTNAME parameter in the merge agent's job ('Run Agent') which
overrides the value returned from the dynamic function eg -HOSTNAME Wales.
Rgds,
Paul Ibison SQL Server MVP, www.replicationanswers.com
(recommended sql server 2000 replication book:
http://www.nwsu.com/0974973602p.html)




Re: Merge Replication - filtering on arbitrary columns Paul Ibison
7/1/2005 9:39:39 AM
Diego,
you can use dynamic filtering for invoices using the HOST_NAME() function
and overriding it in the merge agent's job using the -HOSTNAME parameter.
There are a few details in BOL under 'dynamic filtering' but let me know if
it's unclear.
Rgds,
Paul Ibison SQL Server MVP, www.replicationanswers.com
(recommended sql server 2000 replication book:
http://www.nwsu.com/0974973602p.html)

Re: Merge Replication - filtering on arbitrary columns Diego Mijelshon
7/1/2005 10:04:57 AM
Paul,
Thanks a lot for your answer!

I still have problems understanding how to do that...
Should I use the HOSTNAME for the Site Id?

How do I do that in script and/or Enterprise Manager?

Thanks again!
Diego

"Paul Ibison" <Paul.Ibison@Pygmalion.Com> escribió en el mensaje
news:%23lT%23NfhfFHA.2752@TK2MSFTNGP10.phx.gbl...
[quoted text, click to view]

Re: Merge Replication - filtering on arbitrary columns Diego Mijelshon
7/1/2005 5:12:28 PM
Paul,

I got it working in a few minutes with your advice.
Really-really-really thanks!!!

Diego

[quoted text, click to view]

AddThis Social Bookmark Button