... and datetime column with a trigger may give you what you're looking for
http://sqlserver2000.datab
--- "modifiedDatetime" value is set to current date and time whenever a record is added or updated
create table testTable (
uniqueID int identity,
title varchar(50),
modifiedDateTime datetime default getdate()
)
GO
CREATE TRIGGER dbo.updateTrigger_testTabl
FOR UPDATE
AS
BEGIN
IF NOT UPDATE(modifiedDateTime)
BEGIN
UPDATE dbo.testTable
SET modifiedDateTime = getdate()
WHERE uniqueID IN (SELECT uniqueID FROM inserted)
END
END
GO
insert into testTable (title) values ('a')
insert into testTable (title) values ('b')
-- check default values for new rows
select * from testTable
update testTable set title = left(title, 1) + 'changed'
-- show updated modifiedDateTime values
select * from testTable
Main Topics
Browse All Topics





by: gdemariaPosted on 2007-06-09 at 17:01:50ID: 19250614
The SQL Server timestamp data type has nothing to do with times or dates. SQL Server timestamps are binary numbers that indicate the relative sequence in which data modifications took place in a database. The timestamp data type was originally implemented to support the SQL Server recovery algorithms.
You want to use DATETIME or SMALLDATETIME column for dates