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 Roy Harvey on 07/23/07 13:41

Outside of a trigger, no. But it is exactly the sort of thing that
triggers are for.

Roy Harvey
Beacon Falls, CT

On Mon, 23 Jul 2007 13:27:13 -0000, michael <mharen@gmail.com> wrote:

>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?
>
>Here's an example of what I'm looking for:
>
>CREATE TABLE GuidTest (ID INT PRIMARY KEY IDENTITY, Status INT,
>LastUpdated UNIQUEIDENTIFIER DEFAULT (NEWID()))
>INSERT INTO GuidTest (Status) VALUES (10)
>INSERT INTO GuidTest (Status) VALUES (20)
>INSERT INTO GuidTest (Status) VALUES (30)
>
>SELECT ID, Status, LastUpdated FROM GuidTest
>UPDATE GuidTest SET Status = 31 WHERE ID = 3
>SELECT ID, Status, LastUpdated FROM GuidTest
>-- Would like GUID on ID=3 to be different in second select
>
>DROP TABLE GuidTest
>
>Thanks,
>Michael

 

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

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