Update trigger GetDate() on Indexed

Posted on 2010-01-07
Last Modified: 2012-05-08
I have a table with a DateTime field called "stamp".  The default value is already set for (GetDate()) on insert of new records and wrks fine.
I need that "stamp" field to get updated with GetDate() when that particular record/index is updated.

How can this be done.  I would prefer not to use any history/temp table method here.
Question by:H-SC
    LVL 75

    Accepted Solution

    create trigger tr_u_TableName
    on table_name
    after insert, update
     update t
     set datecolumn = GETDATE()
     from tableName t
     inner join inserted i on t.Primarykey = i.primarykey
    LVL 1

    Author Comment


    Perfect!  Many thanks.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    Performance is the key factor for any successful data integration project, knowing the type of transformation that you’re using is the first step on optimizing the SSIS flow performance, by utilizing the correct transformation or the design alternat…
    Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
    Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
    Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now