Trigger to find specific New Value

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • parshupooja
    New Member
    • Jun 2007
    • 159

    #1

    Trigger to find specific New Value

    Hey All,

    I have table A which has 20 columns. I want to create trigger on table A which should get triggered whenever someone tries to update any value in Table A than trigger should insert new as well old value in table B. For ex:

    Table B
    PK Oldvalue NewValue
    1 Brown Blonde

    I don't want to insert all columns values instead I want to know what specific column has been changed. if two values are changed than I will insert two record for each value.

    any help will be appreciated.
    thanks
  • ck9663
    Recognized Expert Specialist
    • Jun 2007
    • 2878

    #2
    Originally posted by parshupooja
    Hey All,

    I have table A which has 20 columns. I want to create trigger on table A which should get triggered whenever someone tries to update any value in Table A than trigger should insert new as well old value in table B. For ex:

    Table B
    PK Oldvalue NewValue
    1 Brown Blonde

    I don't want to insert all columns values instead I want to know what specific column has been changed. if two values are changed than I will insert two record for each value.

    any help will be appreciated.
    thanks

    Inside your trigger:
    1. Check what columns were updated. Use this function.

    2. Insert the old value of the column from the deleted table.

    3. Insert the new value of the column from the inserted table.

    Consider doing this in a single transaction.

    -- CK

    Comment

    Working...