How to generate timestamp value for binary(8) fiel

2019-08-04 16:57发布

问题:

I need two timestamp fields in my table. One, of the timestamp type for update operation, and the one (binary(8)) for the insert one.

The timestamp type's value is auto generated by the sql server, Where to get the value for that second column from?

回答1:

I'm not sure to understand your problem but :

SELECT CONVERT(varbinary(8), CAST(CONVERT(DATETIME, GETDATE()) AS TIMESTAMP))