Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 619
  • Last Modified:

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
0
Hocke_sweden
Asked:
Hocke_sweden
  • 3
  • 2
  • 2
  • +1
2 Solutions
 
Ephraim WangoyaCommented:

It would be better for you to add a timestamp field to the table
0
 
Hocke_swedenAuthor Commented:
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?


0
 
Ephraim WangoyaCommented:

The timestamp field will be updated everytime data changes in the record
0
Transaction-level recovery for Oracle database

Veeam Explore for Oracle delivers low RTOs and RPOs with agentless transaction log backup and transaction-level recovery of Oracle databases. You can restore the database to a precise point in time, even to a specific transaction.

 
Ephraim WangoyaCommented:
Datatype  TIMESTAMP
0
 
JaseemKCommented:
Can use the system view sys.dm_db_index_usage_stats to check the last_user_update column if the table has indexes.
0
 
Hocke_swedenAuthor Commented:
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
0
 
JaseemKCommented:
Use the object_id column to look up on sysobjects e.g.:

select o.name, s.last_user_update
  from sysobjects o left join sys.dm_db_index_usage_stats s
   on o.id = s.object_id
   where o.xtype = 'U'
go  
0
 
dqmqCommented:
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.  
0

Featured Post

Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

  • 3
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now