I have a table defined (see code snippet below). How can I add a constraint or whatever so that the LastUpdate column is automatically updated anytime the row is changed?
CREATE TABLE dbo.Profiles ( UserName varchar(100) NOT NULL, LastUpdate datetime NOT NULL CONSTRAINT DF_Profiles_LastUpdate DEFAULT (getdate()), FullName varchar(50) NOT NULL, Birthdate smalldatetime NULL, PageSize int NOT NULL CONSTRAINT DF_Profiles_PageSize DEFAULT ((10)), CONSTRAINT PK_Profiles PRIMARY KEY CLUSTERED (UserName ASC), CONSTRAINT FK_Profils_Users FOREIGN KEY (UserName) REFERENCES dbo.Users (UserName) ON UPDATE CASCADE ON DELETE CASCADE )
A default constraint only works on inserts; for an update use a trigger.