August 30, 2010

TIMESTAMP/ROWVERSION and UNIQUEIDENTIFIER in SQL Server

A blog post after very very long gap......

The TIMESTAMP column does not contain any information about date/time. It is not dependent on the system or system date

 
This is just a binary format string, which denote version of row. This value will be incremented by 1 on every insert/update of the record.

 
So it can be used for redundancy check on multiple user updating tables

ROWVERSION and TIMESTAMP in sql server are exactly same, where as there are some difference with UNIQUEIDENTIFIER.


 
  • Size of TIMESTAMP value is 8 bytes whereas size of UNIQUEIDENTIFIER is 16 bytes.
  • TIMESTAMP is not based on system date or time. However, UNIQUEIDENTIFIER value is based on the computer's MAC addresses and system date time.
  • The purpose to TIMESTAMP is to track the operation in tables on the database level. The purpose of UNIQUEIDENTIFIER is to have a unique value assigned to a row (maybe as primary key). It remains unique in any system in the world.