Is there a way to get DateTime value from timestam

2020-02-01 07:10发布

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 imported to the table yesterday and now I need to find out what exactly was imported :(

Is there a way to do it using only timestamp info? Here I found that:

  • Timestamp is a 8 bytes sequential Hex number, that has nothing to do with neither the date nor the time.
  • To get the current value of timestamp, use: @@DBTS.

Perhaps there is a way to find what was timestamp value around specific time? That would help to form a select. Or maybe there is a well known solution?

8条回答
劫难
2楼-- · 2020-02-01 08:08

I think your best bet is to restore a backup from before the inserts and compare the backuped table with the current table.

查看更多
地球回转人心会变
3楼-- · 2020-02-01 08:15

I know it is too late but might help someone else.

Timestamp/RowVersion can be casted to BigInt but in any mean it cannot be compared to datetime.

Following statement is taken from MSDN

The Transact-SQL rowversion data type is not a date or time data type. timestamp is a deprecated synonym for rowversion.

For more detail refer here

查看更多
登录 后发表回答