Results 1 to 2 of 2
  1. #1
    Join Date
    Sep 2010

    Smile Unanswered: insertion in a table by deleting records from another table.

    Hi guys,
    I have a doubt. I have a table named as employee_details where i have 10 rows of records and I have an other table named as employee_details_logHistory which is created just to keep history of employee_details.

    I want result like when i am deleting records from employee_tables after thescope comes to to an end, i want those records in employee_details_LogHistory table so that i can keep history of my past records.

    Structure of both the tables are:-

    emp_name emp_id branch
    --------- --------- ----------

    Last edited by sunny_007; 02-07-11 at 05:32.

  2. #2
    Join Date
    Nov 2004
    Provided Answers: 4
    How will you DELETE records from that table?
    • When you are using a Stored Procedure (SP), just put the necessary INSERT INTO ..._history code in that SP.
    • When you will be using plain SQL (DELETE FROM ...), create a delete trigger that will put the data in your history table.

    You can do a lot more than this. Do a search on "audit trail trigger".
    With kind regards . . . . . SQL Server 2000/2005/2012

    Grabel's Law: 2 is not equal to 3 -- not even for very large values of 2.
    Pat Phelan's Law: 2 very definitely CAN equal 3 -- in at least two programming languages

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts