Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 timestamp .. it automatically updates ?

Author  Topic 

johnstern
Yak Posting Veteran

67 Posts

Posted - 2007-07-10 : 15:13:30
I have a table with a column called "version" that is of type timestamp. I am a somewhat confused on how this actually operates.

-for the column to be (updated/filled) do I have to pass as a part of a insert or update statement some type of value/systax

- or does this column gets automatically updated/created whenever a record is inserted or updated

-how can I see see what are the values in that column ? .. right now in studio 2005 I only see <binary data>

Kristen
Test

22859 Posts

Posted - 2007-07-10 : 15:37:15
It will automatically be "changed" whenever a row is Inserted or Updated.

It has nothing to do with Date / Time, despite the "TIMESTAMP" name keyword The "TIMESTAMP" keyword is deprecated in SQL 2005, I believe, in favour of "ROWVERSION"

You can really only use it to establish whether a particular record has changed, or not.

So ... you could pass the TimeStamp value to your Front End Application, and back again, and check it had not changed before applying the User's data - otherwise another user has beaten them to it.

Or you could compare records in this table with those in another database, only where the TimeStamp data was different (you'd need the column on the Target database to NOT be TimeStamp otherwise any updates there will modify the value!)

Kristen
Go to Top of Page

johnstern
Yak Posting Veteran

67 Posts

Posted - 2007-07-10 : 15:39:59
so technically I should be using ROWVERSION datatype instead ?
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2007-07-10 : 15:45:44
Ideally, yes. They are identical/interchangeable - apart from the word "TIMESTAMP" going out of favour!
Go to Top of Page
   

- Advertisement -