Is there a way to get DateTime value from timestamp type column?

后端 未结 8 713
执笔经年
执笔经年 2020-12-06 17:30

I need a select from table which does not have column that tells when row was inserted, only timestamp column (values like: 0x0000000000530278). Some data was i

8条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-06 18:09

    To identify new rows by timestamp you need to keep track of the timestamps that were there beforehand. In a pinch you could:

    • Restore a previous version somewhere else.
    • Copy the data from both tables into a scratch database.
    • Identify the inserted data from the timestamps present in one but not the other.

    With a minor risk of false positives if anything else has been going on in the DB this will get you a reasonably good difference.

    For a more robust check you could calculate MD5 or SHA-1 hashes with Hashbytes on the row contents to give you a difference with a very low probability of collision (see this wikipedia article on Birthday attacks for a discussion of this problem).

提交回复
热议问题