Merge replication join filter clause can be subquery, self join?

Discussion in 'microsoft.public.sqlserver.replication' started by faustino Dina, Sep 1, 2004.

  1. Hi,

    I need to filter the replicated rows of a table by using a subquery that
    references to itself, or by doing a self join. My filter for the table
    called "aCrediAnti" looks like:

    Select *
    From aCrediAnti t1
    Where t1.ImpSaldoAntiMonOri > 0
    Or exists(select * from aCrediAnti t2
    Where t2.ClaOperProvCrediAnti = t1.ClaOperCrediProv
    And t2.FolOperProvCrediAnti = t1.FolOperCrediProv
    And t2.ClaEmp = t1.ClaEmp
    And t2.ImpSaldoAntiMonOri > 0
    )

    Or may be also in the self join syntax

    Select *
    From aCrediAnti t1
    Left Join aCrediAnti t2
    On t2.ClaOperProvCrediAnti = t1.ClaOperCrediProv
    And t2.FolOperProvCrediAnti = t1.FolOperCrediProv
    And t2.ClaEmp = t1.ClaEmp
    Where t1.ImpSaldoAntiMonOri > 0
    Or (
    Not t2.FolOperProvCrediAnti Is Null
    And t2.ImpSaldoAntiMonOri > 0
    )

    My problem is how to specify such a filter. For both I need to specify table
    aliases (t1, t2) for using them on the join, but neither the Enterprise
    Manager and sp_addmergefilter (script version) allows me to use alias. What
    can I do?

    Thanks in advance
     
    faustino Dina, Sep 1, 2004
    #1
    1. Advertisements

  2. I think a UDF would be ideal for something like this.
     
    Hilary Cotter, Sep 1, 2004
    #2
    1. Advertisements

  3. I think a UDF would be ideal for something like this.
    Thanks! Despite it took me hours to decode what "UDF" means ;-) it looks it
    works

    Faustino
     
    faustino Dina, Sep 1, 2004
    #3
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.