Re: lastmodified

From: Andrew J. Kelly (sqlmvpnooospam_at_shadhawk.com)
Date: 02/22/05


Date: Tue, 22 Feb 2005 15:54:02 -0500

CREATE TRIGGER tr_YourTrigger
ON YourTable
FOR UPDATE

AS

IF @@ROWCOUNT > 0

UPDATE YourTable SET [LastModified] = GETDATE()
WHERE YourPK IN (SELECT b.PK FROM Inserted AS b)

-- 
Andrew J. Kelly  SQL MVP
"Jason" <jlewis@hotmail.com> wrote in message 
news:O$XaerRGFHA.2568@TK2MSFTNGP10.phx.gbl...
> Hi,
>
> Can someone provide me a simple trigger where it updates a lastmodified 
> column.
>
> It should update the column lastmodified whenever an update occurs on all 
> the other columns.
>
> Thnx
> 


Relevant Pages

  • Re: lastmodified
    ... Andrew J. Kelly SQL MVP ... >> UPDATE YourTable SET = GETDATE ... >> Andrew J. Kelly SQL MVP ... >>> Can someone provide me a simple trigger where it updates a lastmodified ...
    (microsoft.public.sqlserver.security)
  • Re: which statement fire the trigger ?
    ... What I meant was you can see the events leading up to the trigger and then ... the trigger execution so you should be able to deduce what caused it. ... Andrew J. Kelly SQL MVP ... >> Andrew J. Kelly SQL MVP ...
    (microsoft.public.sqlserver.programming)
  • Re: Triggers and Data Driven Query
    ... I figured it was some kind of audit trail but I couldn't determine how this: ... You state you can see the trigger firing but you still don't say ... Andrew J. Kelly SQL MVP "David Fuller" wrote in message ...
    (microsoft.public.sqlserver.dts)
  • Re: Newbie Question - Creating Triggers within Stored Procedures
    ... Aaahhhh...thank you, Andrew. ... > You can't have a GO in the stored procedure code. ... > pieces (table creation and trigger etc) in Dynamic sql though. ... > Andrew J. Kelly SQL MVP ...
    (microsoft.public.sqlserver.programming)
  • Re: TRANSACTION QUESTION
    ... a trigger you always have the deleted virtual table. ... Andrew J. Kelly SQL MVP ... > (Just like ORACLE does). ...
    (microsoft.public.sqlserver.programming)