Re: GetDate

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

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: 2010: Essential Diffs?
    ... the view in SQL server is the same thing as a saved select query in access. ... The reason why we don't call them views in Access is because saved queries can also be update queries, delete queries, append queries etc. So using the term "view" has nothing to do with the new JET table engine level triggers. ... Stored procedures don't necessarily mean that they can return tables as data. ... Keep in mind also that these triggers have to be able to run even if VBA or ms access is not installed on your computer. ...
    (comp.databases.ms-access)
  • 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)