Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 record datetime of last modified

Author  Topic 

joriveek
Starting Member

33 Posts

Posted - 2007-04-16 : 09:44:16

I have a datetime field in a table want to use to record the date time last the row/field of the row is modified.

Can I do this in SQL Server 2005 without writing any code/trigger?

Thanks
J.

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-04-16 : 09:46:42
Read about TIMESTAMP in sql server help file

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2007-04-16 : 13:55:27
"Can I do this in SQL Server 2005 without writing any code/trigger?"

1) Make 100% sure that ALL your UPDATE statements "tickle" the Update Date column. Very hard to police, but using a single UPDATE SProc, and enforcing the use of that, might come close

2) Use a Trigger. This will ensure that all updates Tickle the Update Date column, but there is quite a performance hit, unless there are other things that you need the trigger to do.

3) Use a ROWVERSION / TIMESTAMP datatype column This, contrary to what the name suggest will NOT give you the Date + Time the record was updated, but WILL give you a column that is guaranteed to CHANGE whenever an Update occurs.

Kristen
Go to Top of Page
   

- Advertisement -