You are here: Re: Update Guid column on any update to table row « MsSQL Server « IT news, forums, messages
Re: Update Guid column on any update to table row

Posted by Erland Sommarskog on 07/23/07 22:08

michael (mharen@gmail.com) 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@sommarskog.se

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

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация