Thursday, July 26, 2007

Using the SQL Server's Timestamp datatype

The Timestamp datatype is supported by SQL Server 2000 and SQL Server 2005.

It is a good way to indicate the row version because it represents a unique value.

A field defined as 'timestamp' is automatically updated by SQL Server when rows are inserted or updated. You cannot read the content of a timestamp field in the Management Studio. It is encapsulated as 'binary'. ('Timestamp' is stored in 8 bytes as binary(8)).

Why is the timestamp datatype useful?

The timestamp datatype guarantees to be unique across the DB. It is generally used as a DB generated ID in tables.

Other methods?
You can also use a DateTime datatype to indicate a row's version. A datetime field is not automatically updated and is not unique across the database.

Click here to read more about SQL Server 2000/2005 datatypes

No comments: