Results 1 to 3 of 3

Thread: Simple update Trigger with system date

Threaded View

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jul 2001
    Location
    NY
    Posts
    89

    Simple update Trigger with system date

    I am new to using triggers, so I wanted to make sure this made sense before I made this live.

    I want a field on my table to be updated with the current date every time the record is updated.

    I created the following trigger on the table...
    Code:
    CREATE TRIGGER testUpdate ON [dbo].[testTable] 
    FOR UPDATE
    AS 
    UPDATE [dbo].[testTable] 
    SET 
     [dbo].[testTable].[updateMe] = getdate()
    FROM inserted i
    WHERE [testTable].[pkTest] = i.[pkTest]
    I am using SQL Server 2000 and have recursive triggers turned off. Do you see any major flaws with the way I am doing this?

    Thanks,
    AndyL
    Last edited by andyL; Feb 2nd, 2005 at 02:09 PM.

Posting Permissions

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



Click Here to Expand Forum to Full Width