backing up the deleted record

  • I am setting system which has alot of procedures in it.  one of the procedures is to be able to cupture all deleted records into a re-cycle bin table where the record can always be recovered.  has any member ever writen such a code which i can be able to set as my basis as a stored procedure.

    Thanks, Allan.

  • use a trigger instead...

    /*some_master_table_hist has same structure as some_master_table except for a date field

    */

    create trigger tr_delete_example

    on some_master_table

    after delete

    as

    begin

    insert some_msater_table_hist

    select *,getdate()

    from deleted

    end


    Mathew J Kulangara
    sqladventures.blogspot.com

  • An alternative method is to maintain a logically deleted flag on the record and use an INSTEAD OF trigger to flag the record as deleted. You can then use this to allow end user apps to see and undelte the deleted records.

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply