Wrox Programmer Forums
Go Back   Wrox Programmer Forums > SQL Server > SQL Server 2000 > SQL Server 2000
| Search | Today's Posts | Mark Forums Read
SQL Server 2000 General discussion of Microsoft SQL Server -- for topics that don't fit in one of the more specific SQL Server forums. version 2000 only. There's a new forum for SQL Server 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2000 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old July 26th, 2006, 02:46 AM
Authorized User
Join Date: Feb 2006
Location: Karur, Tamildau, India.
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to find the last update time of a table

Hi All,

Is there is any command to find the last update time of the table.


Old July 26th, 2006, 03:24 AM
Friend of Wrox
Join Date: May 2006
Location: Helsingborg, , Sweden.
Posts: 246
Thanks: 0
Thanked 0 Times in 0 Posts


What you can do, is to have a column named LastUpdateTime of datatype DATETIME and then have a trigger updating this column for you whenever a row is updated.

Old July 27th, 2006, 02:48 PM
Friend of Wrox
Join Date: Aug 2004
Location: Orange County, CA, USA.
Posts: 385
Thanks: 0
Thanked 0 Times in 0 Posts

assuming you have a time stamp (as you should) on one of the fields in your table your can select max timestamp.

Old July 27th, 2006, 03:21 PM
Friend of Wrox
Join Date: Jun 2003
Location: Hudson, MA, USA.
Posts: 839
Thanks: 0
Thanked 1 Time in 1 Post

quote:Originally posted by robprell
 assuming you have a time stamp (as you should) on one of the fields in your table your can select max timestamp.
The TimeStamp datatype is very badly misnamed in SQL Server. There is an alias for it called rowversion which describes its purpose much better.

The timestamp datatype does not in fact store a time in it at all; it is simply a value which is automatically incremented every time the row containing it is updated.

The value in it has no useful meaning. A typical use for it is that if you save away the timestamp value when you read a row, then compare that value to the value of the timestamp column at the time you attempt to do an update, if the values are different you can detect that the row must have been changed by somebody else before you got a chance to commit your update.

This can be a very useful form of concurrency control, but it won't tell you the time of the day, which is what the OP is looking for (I think) ...

Jeff Mason
Custom Apps, Inc.
Old July 27th, 2006, 06:40 PM
Wrox Author
Points: 13,255, Level: 49
Points: 13,255, Level: 49 Points: 13,255, Level: 49 Points: 13,255, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Oct 2005
Location: Ohio, USA
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons

dsekar, what I do for my tables is I have 2 columns, an entry_date and change_date column, this tells me 1)when the record was created and 2) when the last modification to the record was made to adapt this to your situation you could SELECT max(entry_date), max(change_date) and then compare the 2, whichever is greater is when the last operation was preformed in your table. (Of course the entry_Date column reflects INSERT's and the chnage date reflects UPDATE's)

"The one language all programmers understand is profanity."

Similar Threads
Thread Thread Starter Forum Replies Last Post
Find difference between table and updated table jasemhi Access 2 September 20th, 2008 04:25 PM
Find Download Time noornmd C# 2005 1 July 30th, 2008 07:12 AM
Update unable to find TableMapping ahager C# 5 June 23rd, 2007 06:20 AM
find time difference? possible using Asp? blueguy Classic ASP Basics 5 January 23rd, 2006 04:49 AM
Update parent table with the sum of child table gbrown SQL Language 2 November 9th, 2004 07:53 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.