Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL Server row date last modified

Tags:

sql

sql-server

A colleague of mine says that SQL Server saves the date and time of last modification in a "hidden column" in each record. I am pretty sure that he said something wrong. Can you confirm this to me?

like image 499
Marco Staffoli Avatar asked Jun 14 '11 13:06

Marco Staffoli


People also ask

How do I find the last modified rows or records in a SQL table?

If there is a DateModified column, or something like that, and you want the 10 most recent rows (for example) you could use a query like: SELECT Top 10 * FROM myTable ORDER BY DateModified DESC; You don't specify the flavor of SQL, so that query might be somewhat different if you're in Oracle, SQL Server, or MS Access.

How do I find the last modified column in SQL Server?

Solution. Using a SQL Server trigger to check if a column is updated, there are two ways this can be done; one is to use the function update(<col name>) and the other is to use columns_updated().

How do you check if a row has been updated in SQL?

One way is to start a transaction, select the contents of the row and compare it to what you're going to update it to. If they don't match, then do the update and end the transaction. If they match, rollback the transaction.


1 Answers

As the others are hinting at, your colleague must be talking gibberish, or referring to something else. The on-disk structure for a record, or page for that sake, does not contain any references to the time of the last update. While you can find info regarding the last update at the object level, no such info is available at the record/row level.

like image 140
Mark S. Rasmussen Avatar answered Sep 24 '22 09:09

Mark S. Rasmussen