What is the proper type for the rowversion (timestamp) data type?
I know it is 8 bytes but i cannot find a link in MSDN which tell if it is a signed or unsigned long
Short answer: it doesn't matter but I'd choose UInt64
.
Details: semantically it's equivalent to binary(8)
so, strictly speaking, it's neither UInt64
nor Int64
but just a chunk of bytes (and in that way it should be managed). That said I'd choose UInt64
because it's an incrementing number to hold row version then (from a logic point of view) 0xFFFFFFFFFFFFFFFF
should be greater than 0
and it's not true for Int64
(because 64 bits set to 1 give -1
and it's less than 0
).
Edit: note that, for reasons known only in the innest SQL Server designers circle, ROWVERSION
is big-endian (while - obviously - bigint
is not) then you first need to reverse bytes, see this answer for a nice implementation.