• Casting binary(16) to a bigint will truncate it. bigint only has 8 bytes of storage.

    You must convert both the first and second sets of 8 bytes to a bigint to get the equivalent value.

    [font="Courier New"]DECLARE @uuid AS UNIQUEIDENTIFIER = NEWID()

    DECLARE @bits AS VARBINARY(16) = CAST(@uuid AS VARBINARY(16))

    SELECT

    CAST(@bits AS BIGINT) 'your answer',

    @bits 'all16bits',

    CAST(SUBSTRING(@bits, 1,8) AS BIGINT) leftBits,

    CAST(SUBSTRING(@bits, 9,8) AS BIGINT) rightBits

    guidaschar: 9E021A10-CD60-4275-A5E0-B208196B07B3

    your answer: -6493994914812328013

    all16bits: 0x101A029E60CD7542A5E0B208196B07B3

    leftBits: 1160242733253489986

    rightBits: -6493994914812328013

    [/font]