Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2004

    Unanswered: how to modify trigger to show time stamp.

    Down below is my tables.
    If I want to add time stamp in log_old_val table.
    what value in log_old_val and cone in trigger have to be modified?


    ************************************************** *****

    --main table
    > create table test (manufacturer varchar(500), score int)
    > insert into test values('Toyota', 1 )
    > insert into test values('Toyota', 2)
    > --logging table
    > create table log_old_val(manufacturer varchar(500), score int, operation
    > varchar(10))
    > --trigger to log old value into log_old_val table.
    > create trigger tr_man on test
    > for update,delete
    > as
    > if @@rowcount = 0
    > return
    > if exists (select * from inserted)
    > if exists (select * from deleted)
    > insert into log_old_val
    > select manufacturer,score, 'update' from deleted
    > if exists (select * from deleted)
    > if not exists (select * from inserted)
    > insert into log_old_val
    > select manufacturer,score, 'delete' from deleted
    > go

  2. #2
    Join Date
    Nov 2002
    ALTER the table and and a datetime column and set it to GetDate() in the TRIGGER?

    I have to be missing something....

    It's a Great Day for America everybody!

    dbforums Yak CorralRadio 'Rita
    dbForums Member List
    I'm Good Once as I ever was

    The physical order of data in a database has no meaning.

Posting Permissions

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