Exforsys
+ Reply to Thread
Results 1 to 2 of 2

Struck with Updation

This is a discussion on Struck with Updation within the MySQL forums, part of the Database category; I have a table designed named as employee. In that various columns and one of the attributes in these employee ...

  1. #1
    Rahulbatra is offline Senior Member Array
    Join Date
    Apr 2006
    Answers
    124

    Exclamation Struck with Updation

    I have a table designed named as employee. In that various columns and one of the attributes in these employee table is up_date. I am struck with a task namely I want to have this up_date files getting updated with current date as soon as a user updates the table. The column must get updated automatically without any intervention by users. How can I achieve this? Kindly help me out.


  2. #2
    rachelle is offline Member Array
    Join Date
    Apr 2006
    Answers
    97
    You can use the triggering concept that will help you to fire the trigger and update the column up_date only when the user updates the table. I have given below the skeleton format of trigger you can make use to finish your process.
    CREATE TRIGGER triggername ON databasename.tablename
    FOR UPDATE
    AS
    update tablename
    set up_date=getdate()
    from tablename
    inner join sample on sample.PKCol = tablename.PKCol

    In the above the table name for you is employee. The getdate() will help to get the current date inserted into the column up_date on the employee table.


Latest Article

Network Security Risk Assessment and Measurement

Read More...