locked
Trigger just affects one record, RRS feed

  • Question

  • Dear all,

     

    I am working on a decoupled sync scenario. I have this delete triggger. The problem is that this just affects one very first row. ie if I delete 5 rows, just the very first row is affected. Can any one help? Thank you.

     

    set ANSI_NULLS ON

    set QUOTED_IDENTIFIER ON

    go

     

     

    ALTER TRIGGER [sales].[patients_delete_trigger] on [sales].[tb_patients] for DELETE

    as

    DECLARE @key int

    SELECT @key= patient_id FROM deleted

    update patients_tracking set delete_timestamp=@@DBTS +1, operation= 'D', update_originator_id=0 WHERE patient_id=@key

     

     

    • Moved by Hengzhe Li Friday, April 22, 2011 8:01 AM (From:SyncFx - Microsoft Sync Framework Database Providers [ReadOnly])
    Sunday, October 19, 2008 2:29 PM

Answers

  • Chuoi,

    This trigger should do the trick:

    ALTER TRIGGER [sales].[patients_delete_trigger] on [sales].[tb_patients] for DELETE

    as

    update t set delete_timestamp=@@DBTS +1, operation= 'D', update_originator_id=0 from patients_tracking t join deleted d on t.patient_id=d.patient_id


    Hope this helps.


    Sunday, October 19, 2008 10:19 PM

All replies

  • Chuoi,

    This trigger should do the trick:

    ALTER TRIGGER [sales].[patients_delete_trigger] on [sales].[tb_patients] for DELETE

    as

    update t set delete_timestamp=@@DBTS +1, operation= 'D', update_originator_id=0 from patients_tracking t join deleted d on t.patient_id=d.patient_id


    Hope this helps.


    Sunday, October 19, 2008 10:19 PM
  • Thank you very much. I got it.

     

    Tuesday, October 21, 2008 2:06 PM