Instead of Delete in replication

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • cfxchange

    Instead of Delete in replication

    I am looking into work-arounds for what seems to be a flaw, or
    "undocument ed feature" of SQL Server replication and Instead of Delete
    triggers not playing together. It seems that if you want to use
    replication then you cannot use Instead Of triggers as it prohibits the
    replication triggers from firing. My delima is that I need to cascade
    delete, but first have the record and all child records inserted into
    associated delete tables (<tablename>_de l). This worked well using
    Instead of delete triggers, but now we are moving to a replication
    environment and it does not synchronize deletes to the publisher or
    subscriber.

    The options I am looking into and the stumbling points they introduce
    are:

    1. Not using Instead Of triggers, but using After to insert the
    deleted record into a <tablename>_d el table (where of course
    <tablename> is the actual table name). The triggers are designed to
    cascade delete all related child records. The problem with this
    option is that there are relationship constraints that cause the
    delete to raise an error complaining about these constraints. Of
    course the child records need to be deleted first, but since this
    runs after the delete I cannot perform this cascade delete via
    trigger (or can I?).

    2. Same as above only using SQL Server 2k's "Cascade Delete"
    option. My question on this is, will the cascade delete execute the
    After Delete triggers for each child table in the relationship? If
    not, is there a way to move these deleted records into
    <tablename>_d el before they are deleted, keeping in mind that it
    must be compatible with merge replication.

    3. Not yet found any information on this, but is it possible to
    manually include information to be replicated after the "Instead Of"
    triggers so that the changes are included in the replication?
    I really appreciate the advice.

  • cfxchange

    #2
    Re: Instead of Delete in replication

    I'm loosing hope. Can anyone point me in the right direction here? Is
    there a way to either mimic an Instead of Delete trigger or to manually
    add records to the MSmerge_tombsto ne table after a Instead Of Delete
    trigger is run?

    Please, any advice is appreciated.

    -Thanks

    Comment

    • cfxchange

      #3
      Re: Instead of Delete in replication

      I'm loosing hope. Can anyone point me in the right direction here? Is
      there a way to either mimic an Instead of Delete trigger or to manually
      add records to the MSmerge_tombsto ne table after a Instead Of Delete
      trigger is run?

      Please, any advice is appreciated.

      -Thanks

      Comment

      • Erland Sommarskog

        #4
        Re: Instead of Delete in replication

        cfxchange (aadams@cfxchan ge.com) writes:[color=blue]
        > I'm loosing hope. Can anyone point me in the right direction here? Is
        > there a way to either mimic an Instead of Delete trigger or to manually
        > add records to the MSmerge_tombsto ne table after a Instead Of Delete
        > trigger is run?
        >
        > Please, any advice is appreciated.[/color]

        The only advice I have is to try microsoft.publi c.sqlserver.rep lication at
        msnews.microsof t.com.


        --
        Erland Sommarskog, SQL Server MVP, esquel@sommarsk og.se

        Books Online for SQL Server SP3 at
        Accelerate your AI application's time to market by harnessing the power of your own data and the built-in AI capabilities of SQL Server 2025, the enterprise database with best-in-class security, performance and availability.

        Comment

        Working...