Link to home
Start Free TrialLog in
Avatar of Hocke_sweden
Hocke_sweden

asked on

Can I find the last update time of a row in MS SQL server 2008 R1

Can I find the last update time of a row in MS SQL server 2008 R1?

I have updated a row, but Im not sure when, I dont have any date or time column
ASKER CERTIFIED SOLUTION
Avatar of Ephraim Wangoya
Ephraim Wangoya
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Hocke_sweden
Hocke_sweden

ASKER

I know, but I haven't done that yet

Can I get timestamp field to update every time the row is changed without changing the sql query?
Should the data type be datetime or?



The timestamp field will be updated everytime data changes in the record
Datatype  TIMESTAMP
Can use the system view sys.dm_db_index_usage_stats to check the last_user_update column if the table has indexes.
It has index, but I m not sure which id it it for that table, how can I see hat?

SELECT * FROM sys.dm_db_index_usage_stats
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Be careful not to get confused betwen a timestamp field and the timestamp datatype.  

A timestamp field contains a datetime, but you must update it yourself:preferably with a trigger if you are serious about monitoring the last update.  

A timestamp datatype is updated automatically, but it does not contain a date or time!!!  For the resulting confusion, the timestamp datatype has been deprecated and replaced with the rowversion datatype which works exactly the same.