Possible Duplicate:
How to make a search function for sql database , and how to get time when info from a table was edited?
How can I determine the last time when records have been inserted,
updated or deleted for a table ?
someone told me
select *
from sys.dm_db_index_usage_stats
where database_id = db_id( 'readpasttest' )
But I don’t know how to use it I have a database table on asp.net site where I add informations like this:
edit-1.Name : Jax
edit-2.Age : 24
edit-3.Code : 12515
so when the users edit something lets say the name Jax it will be like this
edit-1.Name : newName - This was edited last time : the time/day !
Please help ,ty
For changes, you can add a
datetimecolumn to the table called ‘LastModified’ or something like that, and write the current date/time to it every time you write a record.Alternatively, if you need to know when a record was deleted you can write a trigger that intercepts inserts/updates/deletes to the table in question, and write the timestamp value to another table, along with identifying information about the affected record.
The best way is to implement ‘soft deletes’ where a record is marked with some kind of status value (e.g. a ‘IsDeleted’ column) that can be flipped and subsequently ignored by other code in the application when reading from the table.