Re: GetDate

From: Tom Moreau (tom_at_dont.spam.me.cips.ca)
Date: 03/30/04


Date: Tue, 30 Mar 2004 10:32:46 -0500

Actually, this functionality has been in place for over a decade in the form
of triggers:

create trigger triu_MyTable on MyTable after insert, update
as
if @@ROWCOUNT = 0 return

update MyTable
set
    LastUpdateDateTime = getdate ()
where
    PK in (select PK from inserted)
go

-- 
Tom
---------------------------------------------------------------
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
SQL Server MVP
Columnist, SQL Server Professional
Toronto, ON Canada
www.pinnaclepublishing.com/sql
"Mike Kruchten" <mkruchten@fsisolutions.com> wrote in message
news:#0KV3omFEHA.1240@TK2MSFTNGP10.phx.gbl...
Would be nice, wouldn't it. Sybase SQL Anywhere has this functionality.
Maybe next year Yukon will have it.
Mike Kruchten
"Keith" <@.> wrote in message news:OyxRm0jFEHA.688@tk2msftngp13.phx.gbl...
> I am using GetDate() as the default value on selected fields to record the
> date/time that a record is inserted into my tables, however, is it
possible
> to use a similar procedure to automatically insert the date/time into a
> field, but ONLY if the record is subject to an update - thus recording the
> date/time a record was last updated.
>
> Thanks
>
>


Relevant Pages

  • Re: GetDate
    ... However we removed these for performance reasons on several tables, ... Maybe using INSTEAD OF triggers for this would have helped the speed, ... Columnist, SQL Server Professional ... > date/time that a record is inserted into my tables, however, is it ...
    (microsoft.public.sqlserver.server)
  • Re: New to SQL server
    ... it is called triggers. ... ANYTHING THAT YOU CAN DO IN JET IS BABY TALK COMPARED TO WHAT WE CAN DO ... anything that you can do in JET that I can't do in SQL Server ... self-referencing FKs and inline constraints. ...
    (microsoft.public.access.adp.sqlserver)
  • Re: full-Text Search questions
    ... I will search SQL Server BOL for information. ... TopCo Site / Employees ... The functionality in STS was to search the entire set of sites. ...
    (microsoft.public.sharepoint.portalserver.development)
  • Re: Return subquery rows as one delimited column
    ... and concatenates them together - this will be very slow!! ... For SQL Server 2005, there's a method that uses documented functionality ...
    (comp.databases.ms-sqlserver)
  • Re: I have two questions about the TableAdapter Configuration Wizard
    ... something to do with the difficulty in adding functionality to VS2005. ... Hitchhiker's Guide to Visual Studio and SQL Server ... I want to have a TableAdapter that encapsulates a bunch of stored ... I might have 10 delete sprocs that I want to put into one ...
    (microsoft.public.dotnet.framework.adonet)