Re: Update Guid column on any update to table row



michael (mharen@xxxxxxxxx) writes:
I have a column Last_Updated (uniqueidentifier) on a table. I'd like
this column to get a new guid (NEWID()) each time any column in the
row is updated.

Is there an automatic way to do this outside of triggers?

I don't know what the purpose with this guid is, but there is a special
data type in SQL Server, timestamp, for this purpose. A timestamp is a
binary(8) values with no relation to date and time. Such a column is
automatically updated each time a row is touched. Furthermore, the
value is database-unique and monotonically growing.


--
Erland Sommarskog, SQL Server MVP, esquel@xxxxxxxxxxxxx

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx
.



Relevant Pages

  • Re: How to handle PK field using Int datatype when moved to a new serv
    ... stick with bigint unless you have a reason to go to GUID. ... Erland Sommarskog, SQL Server MVP, esquel@xxxxxxxxxxxxx ...
    (microsoft.public.sqlserver.programming)
  • Re: bulk inserting uniqueidentifier column
    ... I use in bulk insert a format file like this: ... first record extends into the GUID in the second record, ... Erland Sommarskog, SQL Server MVP, esquel@xxxxxxxxxxxxx ... Books Online for SQL Server 2005 at ...
    (comp.databases.ms-sqlserver)
  • Re: Adding rows to a dataset where the primary key is type System.
    ... UuidCreatemethod to create the guid. ... Michael Hockstein ... NewID comes to mind. ... Hitchhiker's Guide to Visual Studio and SQL Server ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: Debugging and Guids
    ... ASP.NET 2 application where the GUID was read from a sql server database. ... Michael Nemtsev:: blog: http://spaces.msn.com/laflour ...
    (microsoft.public.dotnet.general)
  • Re: Would special character cause insertion problem?
    ... "Actually sql server has successfully captured one record. ... does not go out in the wild to capture "capture rows", ... why not use a GUID if you want a ... Books Online for SQL Server 2005 athttp://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books ... ...
    (comp.databases.ms-sqlserver)