Partager via


Timestamp data type in SQL Server

Just looking at the timestamp data type, I realized that in SQL Server this exposes an automatically generated unique binary number (basically to help in version-stamping the rows). The timestamp data type is just an incrementing number and has nothing to do with preserving a date or a time. To actually capture a date or time, just use your good old datetime data type!

Comments

  • Anonymous
    October 14, 2007
    PingBack from http://www.artofbam.com/wordpress/?p=8449

  • Anonymous
    October 14, 2007
    Then why anyone should use that (particuarly with using uniqueidentifier as primary key)? Thanks, Jwalant Natvarlal Soneji

  • Anonymous
    October 14, 2007
    You would want to use that when you need to determine whether any row has changed since the last read - if there's any change in the row - timestamp gets updated. I agree its a poor candidate for primary key.

  • Anonymous
    October 14, 2007
    But is ideal if you are trying to keep to tables in sync. What is the highest timestamp I have OK lets import all those records with a higher timestamp as they have changes since I last grabbed them. Paul Baxter

  • Anonymous
    October 15, 2007
    You got it!