views:

1034

answers:

2

How can a Table's Last Modified date be returned in SQL Server 2005?

I did see one on the Table Properties page. There is a Created Date but no Modified date.

If it is not available, what would be some other ways to add this functionality?

Here are a few that come to mind:

  1. Add another column, to the table, that a trigger would update whenever the record was added or changed. The one con, to this approach, is Deletes would not be tracked.
  2. Add another table (TableModifiedDate) that would contain a Table Name and Modified Date. Then add a trigger to the tables that you want to track which will update TableModifiedDate.
+1  A: 

Paul Nielson's AutoAudit is a quick and effective way of retro-fitting this to a database. He has a demo screencast here.

Mitch Wheat
This is looks really cool and might solve a seperate problem where our current logging solution does not get all changes because it is implememnted on the front end but does not catch the DBAs changes done through SQL Server Manangement Studio. AutoAudit on CodePlex http://www.codeplex.com/AutoAudit
Gerhard Weiss
Hi @Gerhard: that's the link I included in the post... :-)
Mitch Wheat
+2  A: 

This Blog entry contains information on how to do it on SQL Server 2008 and 2005.

  • On 2008: using the new Server Auditing feature
  • On 2005: using Dynamic Management Views (DMV)

SQL Server 2000 has no built-in possibility to do it, so you'll need a workaround, like you already mentioned.

MicSim