TRIGGER HELP!

  • Here's the scenario:

    I have three columns: submitDate, openDate, completeDate. I want to write a Trigger that will update each of these dates based on the value of the 'status' column. In other words, when a user submits a request, the status is set to 'open'. When a administrator clicks on the form in the queue that I have created, the status is auto changed to 'being processed'. When the admin clicks on the "COMPLETE" button on the form (web-side), the status is auto changed to 'complete', Now, I want to timeDate stamp each of these and place them in their respective columns. My obvious problem is getting the Trigger to update a different column based on the VALUE of the column and not just that the column was updated. All my dates change to the same thing, or none change at all or I get syntax errors when trying to "theorize" on syntax. Can someone help?

  • use if

    create trigger

    as

    if (select status from inserted) = 'Complete'

    update table

    set completedate = getdate()

    from inserted

    where table.pk = inserted.pk

    else if (select status from inserted) = 'being processed'

    ....

    Steve Jones

    sjones@sqlservercentral.com

    http://www.sqlservercentral.com/columnists/sjones

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

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