I currently have a function which accepts a varbinary as it allows me to pass the timestamp for comparison against other timestamps without casting it however my comparisons are failing as the timestamp is stored as bigint and then converted to varbinary and then passed to the function however the cast does not store the timestamp as 16 bytes but 8 bytes which cause the comparison to return false.
I.E:
DECLARE @Test1 varbinary(16) = CAST(506693 as varbinary(16)) -- 0x0007BB45
DECLARE @Test2 timestamp = CAST(506693 as Timestamp) -- 0x000000000007BB45
When I compare Test1 with a timestamp to the timestamp is greater than test1 it returns false, however if I use Test2 it returns true (which is correct)
Is there a way to make the varbinary store the additional zeros?