Convert to bigint

  • PHXHoward (7/12/2011)


    Why do these give me different results? 0x80 has an even number of characters.

    select CONVERT (bigint, convert(VARBINARY(20),'0x80') ,1)

    select CONVERT (bigint, 0x80 ,1)

    You're asking different questions. In the first one '0x80' is a string, see demo below:

    SELECT CONVERT (BIGINT, CONVERT(VARBINARY(20), '0x80', 1), 1) -- string

    SELECT CONVERT (BIGINT, CONVERT(VARBINARY(20), 0x80), 1) -- binary

    SELECT CONVERT (BIGINT, 0x80, 1) -- the other one

  • Oh I see. I was missing the style 1 on the inner convert. Needed it for both. Thanks Paul!

    edit: inner was missing, not outer

Viewing 2 posts - 16 through 16 (of 16 total)

You must be logged in to reply to this topic. Login to reply