2
Reply

How to write a multiple row delete trigger in sqlserver.... eg--I want to delete 5 rows in abc table and those 5 rows should be updated in xyz table....

sudeep kumar

sudeep kumar

15y
7.9k
0
Reply

    Do you want to create a delete archive??? following trigger will explain you how to create a delete archiving mechanism in SQL Server


    CREATE TRIGGER trTriggerName  
    ON abc
    FOR DELETE AS      
    begin      
       insert into xyz select * from deleted
    end  
      
    (Whenever you delete or update any record in SQL Server the orginal records are updated in DELETED and UPDATED temporary tables respectively.)

    In above trigger whatever record you delete from ABC table will be updated in XYZ table; conditionaly both the tables are having same schema (table structure).



    try this..

    update top(5) table1 set col='a'

    delete top(1) table1